Skip to content

Repository files navigation

Mickey

mickey.svg

Lightweight front-end framework for creating React and Redux based app painlessly.

Totally base on redux, redux-saga and react-router, very friendly to redux users.

(Inspired by dva)

MIT License

NPM VersionBuild StatusCoverage StatusNPM downloadsDependenciesPackage Quality

查看中文

Features

Quick Start

Use create-react-app to create an app:

$ npm i -g create-react-app
$ create-react-app my-app

Then install mickey from npm:

$ cd my-app
$ npm install mickey --save
$ npm start

Update index.js as follow:

importReactfrom'react'importcreateApp,{connect,injectActions}from'mickey'// 1. Initializeconstapp=createApp()// 2. Modelapp.model({namespace: 'counter',state: {count: 0,loading: false,},increment: state=>({ ...state,count: state.count+1}),decrement: state=>({ ...state,count: state.count-1}),incrementAsync: {*effect(payload,{ call },{ succeed }){constdelay=timeout=>newPromise((resolve)=>{setTimeout(resolve,timeout)})yieldcall(delay,2000)yieldsucceed()},prepare: state=>({ ...state,loading: true}),succeed: state=>({ ...state,count: state.count+1,loading: false}),},})// 3. ComponentconstComp=(props)=>(<div><h1>{props.counter.count}</h1><buttononClick={()=>props.actions.counter.decrement()}>-</button><buttononClick={()=>props.actions.counter.increment()}>+</button><buttononClick={()=>props.actions.counter.incrementAsync()}>+ Async</button></div>)// 4. Connect state with component and inject `actions`constApp=injectActions(connect(state=>({counter: state.counter})(Comp)))// 5. Viewapp.render(<App/>,document.getElementById('root'))

Examples

More

Related

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.

About

🤠 Lightweight front-end framework for creating React and Redux based app painlessly.

Topics

Resources

Stars

25 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages