jfreact-redux
v1.0.1
Published
**Summary** It allows you to use redux as convenient and simple as vue, and you can also directly copy vuex store module files
Downloads
3
Readme
jfreact-redux
Summary It allows you to use redux as convenient and simple as vue, and you can also directly copy vuex store module files
Install
npm i jfreact-redux --save
how to use
- Create a store directory under src as:
store
│ README.md
│
└───modules
│ │ example.js
│ │ example2.js
│
└───index.js
src/store/index.js
code as:
import { createReactStore } from 'jfreact-redux'
import personal from './modules/personal'
import { vueImStore as im } from '@/imsdk/api'
export default createReactStore({
modules: {
personal,
im
},
})
example.js
code as:
const data = {
namespaced: true,
state: () => ({
name: '',
age: 0,
sex: ''
}),
mutations: {
INIT_PERSONAL(state, params) {
console.info('执行', state, params)
state.name = params.name
state.age = params.age
state.sex = params.sex
},
},
actions: {
initPersonal(context, params) {
context.commit('', {
name: '芝士奶盖',
age: 24,
sex: '男'
})
}
}
}
export default data
src/index.js
code as:
import store from '@/store'
ReactDOM.render(
<Provider store={store}>
<App />
<div id="cust-map-cont"></div>
</Provider>,
document.getElementById('root')
)
- inject to your component as:
import { mapState } from 'jfreact-redux'
@mapState(['im'])
class PrivateRoom extends React.component {
}