react-mvp
Lightweight Model-View-Presenter framework for React.
Bootstrapped with create-react-app-minimal.
Getting started
Installing
npm install react-mvp
Usage
Declare your view, as a "dumb" component, with all input and output taking place through props (values and event handlers).
{ const todoList newItem onAddNewItem onChangeNewItem = thisprops return <div> <div> <label>Enter </label> <input type="text" onChange=onChangeNewItem value=newItem /> <button onClick=onAddNewItem>Add</button> </div> <ul> todoList </ul> </div> }
Then declare your model, with any needed defaults.
todoList = newItem = ''
Then declare your presenter, as a class that inherits from Presenter
in react-mvp.
{ supermodel setModel; } this this
Finally, hook them all up together, using connect
, and render the result. (This example assumes a web-browser.)
const App = ReactDOM
Contributing
You're welcome to fork and/or contribute pull-requests and issues to the project.
Cloning and installing
git clone https://github.com/jonathanconway/react-mvpcd react-mvpnpm install
Running tests
npm test