在“ Connect(Notifs)”的上下文或道具中找不到“ store”

时间:2020-08-10 12:34:08

标签: javascript reactjs

我想将redux-notifications连接到我的项目,但这给了我。

App.js

  class App extends React.Component {
  componentDidMount() {
    this.props.initializeApp();
  }
  render() {
    return (
        <Navbar />
    )
  }
}

const mapStateToProps = (state) => ({
  initialized: state.app.initialized,
  authenticated: state.auth.token !== null
})

let AppContainer = compose(
  withRouter,
  connect(mapStateToProps, { initializeApp }))(App);

const MaterialsApp = (props) => {
  return (<div>
    <Provider store={store}>
      <Notifs />
      <Router history={history} >
        <AppContainer />
      </Router>
    </Provider>
  </div>
  );
}

store.js

 import { reducer as notifReducer } from 'redux-notifications';

const reducers = combineReducers({
  notifs: notifReducer,
});

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(reducers, composeEnhancers(applyMiddleware(thunk)));

问题出在哪里?我试图重写app.js和index.js,但这又给了我

0 个答案:

没有答案