警告:道具类型失败:道具“store”在“Provider”中被标记为必需,但其值为“undefined”。在供应商
Warning: Failed prop type: The prop `store` is marked as required in `Provider`, but its value is `undefined`. in Provider
如何解决react-redux项目中的这个错误
error screenshot
警告:失败的道具类型:道具 store
在 Provider
中被标记为必需,但其值为 undefined
。
在供应商
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
import SignUp from './Components/SignUp'
import SignIn from './Components/SignIn'
import Home from './Components/Home'
import { Router, Route, hashHistory, IndexRoute, browserHistory } from 'react-router';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import {firebaseApp} from './Database/firebaseApp'
import {Provider} from 'react-redux'
import {store} from './Store/Store'
import {logUser} from './Store/Actions'
ReactDOM.render(
<MuiThemeProvider>
<Provider store={store}>
<Router history={browserHistory} >
<Route path="/signup" component={SignUp} ></Route>
<Route path="/signin" component={SignIn} ></Route>
<Route path="/home" component={Home} ></Route>
</Router>
</Provider>
</MuiThemeProvider>
,
document.getElementById('root')
);
//店铺代码如下
import { createStore, applyMiddleware,combineReducers } from 'redux';
import thunk from 'redux-thunk';
import {createLogger} from "redux-logger";
//import logger from 'redux-logger'
//import rootReducer from './Reducers/rootReducer'
import {authReducer} from "./Reducers/authReducer"
const rootReducer = combineReducers({
authReducer
})
const logger = createLogger();
let store = createStore(rootReducer, applyMiddleware(thunk, logger) );
export default store;
您默认导出 store
:export default store;
您需要这样导入:import store from './Store/Store'
导出有两种:
export myVar
必须与 {
和 }
一起导入
export default myVar
必须在没有 {
和 }
的情况下导入
这对于 export/import 来自文件的多个 variables/functions 很有用:
// file.js
export a;
export b;
export default c;
//otherfile.js
import c, { a , b} from './file';
如何解决react-redux项目中的这个错误
error screenshot
警告:失败的道具类型:道具 store
在 Provider
中被标记为必需,但其值为 undefined
。
在供应商
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
import SignUp from './Components/SignUp'
import SignIn from './Components/SignIn'
import Home from './Components/Home'
import { Router, Route, hashHistory, IndexRoute, browserHistory } from 'react-router';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import {firebaseApp} from './Database/firebaseApp'
import {Provider} from 'react-redux'
import {store} from './Store/Store'
import {logUser} from './Store/Actions'
ReactDOM.render(
<MuiThemeProvider>
<Provider store={store}>
<Router history={browserHistory} >
<Route path="/signup" component={SignUp} ></Route>
<Route path="/signin" component={SignIn} ></Route>
<Route path="/home" component={Home} ></Route>
</Router>
</Provider>
</MuiThemeProvider>
,
document.getElementById('root')
);
//店铺代码如下
import { createStore, applyMiddleware,combineReducers } from 'redux';
import thunk from 'redux-thunk';
import {createLogger} from "redux-logger";
//import logger from 'redux-logger'
//import rootReducer from './Reducers/rootReducer'
import {authReducer} from "./Reducers/authReducer"
const rootReducer = combineReducers({
authReducer
})
const logger = createLogger();
let store = createStore(rootReducer, applyMiddleware(thunk, logger) );
export default store;
您默认导出 store
:export default store;
您需要这样导入:import store from './Store/Store'
导出有两种:
export myVar
必须与{
和}
一起导入
export default myVar
必须在没有{
和}
的情况下导入
这对于 export/import 来自文件的多个 variables/functions 很有用:
// file.js
export a;
export b;
export default c;
//otherfile.js
import c, { a , b} from './file';