reactjs - Warning: Failed prop type: The prop `store` is marked as required in `Provider`, but its value is `undefined`. in Provider -


how resolve error in react-redux project error screenshot warning: failed prop type: prop store marked required in provider, value undefined. in provider

import react 'react'; import reactdom 'react-dom'; import app './app'; import './index.css'; import signup './components/signup' import signin './components/signin' import home './components/home' import { router, route, hashhistory, indexroute, browserhistory } 'react-router'; import muithemeprovider 'material-ui/styles/muithemeprovider'; import {firebaseapp} './database/firebaseapp' import {provider} 'react-redux' import {store} './store/store' import {loguser} './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') ); 

//store code below

import { createstore, applymiddleware,combinereducers } 'redux'; import thunk 'redux-thunk'; import {createlogger} "redux-logger"; //import logger 'redux-logger'  //import rootreducer './reducers/rootreducer' import {authreducer} "./reducers/authreducer"  const rootreducer = combinereducers({     authreducer }) const logger = createlogger();  let store = createstore(rootreducer, applymiddleware(thunk, logger) );  export default store; 

you export store default: export default store;

you need import way: import store './store/store'

there 2 kinds of export:

  • export myvar must imported { , }
  • export default myvar must imported without { , }

this useful export/import multiple variables/functions file:

// file.js export a; export b; export default c;  //otherfile.js import c, { , b} './file'; 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -