你如果真的善于给人答案,那么请你告诉我,此刻我的意义是为了什么
每个modal多要带上这个方法,我叫做 快照
方法
* snapShot({payload}, {call, put}) {
var state = yield getState(namespace)
var newState = {
...state,
...payload
}
yield setState(newState)(namespace)
},
写一个pageRedux
作用:为每一个组件或者页面注入store+setStore()方法
export default function (WrappedComponent) {
class MyComponent extends React.Component {
constructor(props) {
super()
initStoreFromLocal.call(props)
this.getStore = getStoreUtil.bind(props)
this.setStore = setStoreUtil.bind(props)
}
componentWillMount() {
var self = this
}
render() {
return (<WrappedComponent {...this.props}
getStore={this.getStore}
setStore={this.setStore}/>)
}
}
var HelloWorld = connect(function (state, myProps) {
return {_store: state, store: state, ...myProps}
}, function (dispatch, ownProps) {
return {
dispatch,
}
})(MyComponent)
return HelloWorld
}
使用:
this.props.setStore("app.asdasd",value...)
格式:
[model_namespane.stateKey],value
特点:每次修改redux都会在localstage保存内存,起到缓存作用
如何拿到redux?
props.store.[namespace]
小的demo看看效果