dva
Front-end framework based on react, redux, react-redux, react-router and redux-saga, inspired by elm and choo.
Documents
Getting Started
Install
$ npm install --save dva
Usage Example
Let's create an count app that changes when user click the + or - button.
import React from 'react';
import dva, { connect } from 'dva';
import { Router, Route } from 'dva/router';
const app = dva();
app.model({
namespace: 'count',
state: 0,
reducers: {
['count/add' ](count) { return count + 1 },
['count/minus'](count) { return count - 1 },
},
});
const App = connect(({ count }) => ({
count
}))(function(props) {
return (
<div>
<h2>{ props.count }</h2>
<button key="add" onClick={() => { props.dispatch({type: 'count/add'})}}>+</button>
<button key="minus" onClick={() => { props.dispatch({type: 'count/minus'})}}>-</button>
</div>
);
});
app.router(({ history }) =>
<Router history={history}>
<Route path="/" component={App} />
</Router>
);
app.start('root');
Examples
License
MIT