Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

yzf-react-storage

yzflhez13ISC1.3.0

react数据管理(dva、redux...)

react, 数据管理, react-storage

readme

完整压缩版-欢迎使用(45 kB)

** 版权属于yzflhez@126.com

react 数据管理组件;参考dva

~ npm install yzf-react-storage --save

~ import { dva, connect } from 'yzf-react-storage';

index.jsx 文件

class App2 extends React.Component {

constructor(props, context) {

super(props, context);

this.state = {

//

};

}

componentDidMount() {

console.log(this.props)

const {index, dispatch} = this.props;

setTimeout(() => {

dispatch({

type: 'index/loadFn',

payload: '323232'

})

}, 3000)

}

render() { // 活动效果监测与分析 / 辅助活动方案决策 / 圈人、圈店、圈券、圈商品

const { index } = this.props;

console.log(index)

return (

21211212

);

}

}

const stateFn = (state) => {

return state;

}

const App3 = connect(App2, stateFn);

class App extends React.Component {

constructor(props, context) {

super(props, context);

this.state = {

//

};

}

render() { // 活动效果监测与分析 / 辅助活动方案决策 / 圈人、圈店、圈券、圈商品

const { visible } = this.state;

return (

21


<App3/>

);

}

}

import myModel from './model.jsx';

const AppD = dva();

model.jsx

export default {

namespace: 'index',

state: {

// index

loadData: '21',

},

effects: {

async loadFn({ payload, state }, { call, put }) { #### 登录

// state 所以存储空间

const loadAjax = () => {

return new Promise((res, rej) => {

setTimeout(() => {

res(32)

}, 1000)

})

}

console.log(payload)

const Data = await call(loadAjax, payload);

console.log(payload)

await put({

type: 'save',

payload: {

loadData: payload

}

});

},

},

reducers: {

save(state, action) {

return {...state, ...action.payload};

},

},

};

AppD.model(myModel);

ReactDOM.render((<AppD ><App/></AppD>), document.getElementById('react-content'));

ReactDOM.render(<AppD >{App}</AppD>, document.getElementById('react-content'));