1.0.3 • Published 5 years ago

amend-connect v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

使用方式

在store中建一个分类的文件夹,里面包含有actionCreators.js、actionTypes.js、defaultState.js、index.js actionCreators.js中写方法,类似于ajax请求,然后在index.js中进行配置

import { connect } from 'amend-connect'
// 给connect添加可以配置的atcionCreators
import actionCreators from './actionCreators'
connect.addActionCreator({
    book: actionCreators
})

然后在reducer.js中引用

在src中的index.js中 import { Provider } from 'react-redux' import store from './store'

<Provider store={store}>
    <BrowserRouter>
        <App />
    </BrowserRouter>
</Provider>

最后就是在需要使用store的组件中 import { connect } from 'amend-connect'

export default connect(Uicomponent, [{name: 'name', state: ['list']}])

第一个参数是你要包裹的组件,第二个参数是先要获取的reducer模块的内容 name : 模块名字 state : 先要获取state的名字【不写的话,name模块中的state都返回】