1.1.0 • Published 6 years ago
ljcstore v1.1.0
_redux
// if you use es5
var { createStore } = require('ljcstore')
// if you use es6
var { createStore } = import('ljcstore')
// you reducer should like this
var reducer = (state, action) => {
if (!state) {
state = {
// you shound init you state here
}
return state
}
......
}
var store = createStore(reducer)
store.getState()
store.dispatch(action)
store.subScribe(func)
_react-redux
you should put you store
at the top Component's context
, and the son can use the connect
to get that state, and the connect's useAge is the same as react-redux
, you should give some arguments like mapStateToProps
or mapDispatchToProps
etc.
// if you use es5
var { connect } = require('ljcstore')
// if you use es6
var { connect } = import('ljcstore')
class Test extends React.Component {
render () {
}
}
const mapStateToProps = (state) => {
}
const mapDispatchToProps = (dispatch) => {
}
export default connect(mapStateToProps, mapDispatchToProps)(Test)