React Axiom
React Axiom is a way to use models with React.
Links
Getting Started
Install React Axiom:
npm install --save react-axiom
To build a model class for an application, import and extend the React Axiom Model
class:
; {}; const task1 = completed: false description: 'Hello world';
When instantiating a model, the Model
base class will meta-program helper methods to set and access state. See the model reference for more information on these helper methods. For this particular example they are the following:
task1;//=> false task1;task1;//=> true task1;//=> 'Hello world' task1;//=> true task1;task1;//=> 'Hello again'
Create a React component to display the task model and wrap the component with the higher-order React Axiom subscribe()
function to ensure that the React component will re-render when the model's state changes:
;; from ReactComponent { const task = thisprops; return <li> <input type="checkbox" onClick= task checked=task /> task </li> ; } const TaskSubscriber = ;
Finally, use the wrapped component like any other React component and pass the model instance as a property:
ReactDOM;