Skip to content
/ dva Public
forked from dvajs/dva

🌱 React and redux based, lightweight and elm-style framework. (Inspired by elm and choo)

License

Notifications You must be signed in to change notification settings

panyifei/dva

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dva

NPM version

Front-end framework based on react, redux, react-redux, react-router and redux-saga, inspired by elm and choo.


Quick start with count

import React from 'react';
import dva, { connect } from 'dva';
import { Route } from 'dva/router';

// Initialize
const app = dva();

// Model
app.model({
  namespace: 'count',
  state: 0,
  reducers: {
    ['count/add'  ](count) { return count + 1 },
    ['count/minus'](count) { return count - 1 },
  },
});

// View
const Count = ({ count, dispatch }) =>
  <div>
    <h2>{ count }</h2>
    <button key="add" onClick={() => { dispatch({type: 'count/add'})}}>+</button>
    <button key="minus" onClick={() => { dispatch({type: 'count/minus'})}}>-</button>
  </div>
const HomePage = connect(({ count }) => ({ count }))(Count);

// Router
app.router(
  <Route path="/" component={HomePage} />
);

// Start
app.start('root');

More examples

About

🌱 React and redux based, lightweight and elm-style framework. (Inspired by elm and choo)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.1%
  • HTML 0.9%