edux请求数据流程

edux请求数据流程

redux请求数据流程

store里面的index.js文件

 import {createStore,combineReducers,applyMiddleware} from "redux"
import reduxThunk from "redux-thunk"
import user from "./reducers/user"/*团队合作各自引入自己的模块*/
import {composeWithDevTools} from "redux-devtools-extension" const reducers=combineReducers({
user 模块在这里写入
}) const store=createStore(reducers,composeWithDevTools(applyMiddleware(reduxThunk))) export default store

store里面的reducers文件里面的user.js

 import {handleActions} from "redux-actions"

 const defaultState={

 }

 export default handleActions({

 },defaultState)

在入口文件引入

import React from 'react';
import ReactDOM from 'react-dom'; import App from './App'; import store from "./store"
import { Provider } from "react-redux"
ReactDOM.render(
<Provider store={store}>/*在这里注入store全局可以使用store*/
<App />
</Provider>
, document.getElementById('root'));
05-27 19:58