question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I am receiving weird error regarding GatePage.

See original GitHub issue

Error

Could not find "store" in either the context or props of "Connect(GatedPage)". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(GatedPage)".

Main index

import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import { BrowserRouter } from "react-router-dom";
import "./assets/css/main.scss";
import App from "./App";
import { configureStore } from "./store";
import { verifyCredentials } from "./lib";
import * as serviceWorker from "./utils/serviceWorker";

const store = configureStore();
verifyCredentials(store);

ReactDOM.render(
  <Provider store={store}>
    <BrowserRouter>
      <App />
    </BrowserRouter>
  </Provider>,
  document.getElementById("root")
);

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister();

Routes

import React, { Component, Fragment } from "react";
import { Route } from "react-router-dom";
import { generateRequireSignInWrapper } from "redux-token-auth";

import { Home, Login, Protected, SignUp } from "../containers";
import {
  ROOT_PATH,
  SIGN_IN_PATH,
  SIGN_UP_PATH,
  PROTECTED_PATH
} from "../constants/routes";

const requireSignIn = generateRequireSignInWrapper({
  redirectPathIfNotSignedIn: "/login"
});

export default class Routes extends Component {
  render() {
    return (
      <Fragment>
        <Route exact path={ROOT_PATH} component={Home} />
        <Route path={PROTECTED_PATH} component={requireSignIn(Protected)} />
        <Route path={SIGN_IN_PATH} component={Login} />
        <Route path={SIGN_UP_PATH} component={SignUp} />
      </Fragment>
    );
  }
}

Main App container

import React, { Component } from "react";

import { withHead } from "../lib";
import { Layout } from "../components";
import Routes from "../Routes";

class App extends Component {
  render() {
    return (
      <Layout>
        <Routes />
      </Layout>
    );
  }
}

export default withHead(App);

Versions

  "dependencies": {
    "react": "^16.7.0",
    "react-dom": "^16.7.0",
    "react-redux": "^6.0.0",
    "react-router-dom": "^4.3.1",
    "react-scripts": "2.1.2",
    "redux": "^4.0.1",
    "redux-thunk": "^2.3.0",
    "redux-token-auth": "^0.19.0",
  }

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:8
  • Comments:8

github_iconTop GitHub Comments

11reactions
gtourniecommented, May 20, 2019

you can also just replace the requireSignIn function by this one:

import React, { useEffect } from 'react'
import { compose } from 'redux'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'

const LOGIN_PATH = '/login'

[...]

const requireSignIn = Component =>
  compose(
    withRouter,
    connect(state => ({ authUser: state.reduxTokenAuth.currentUser })),
  )(({ authUser, ...props }) => {
    useEffect(() => {
      if (!authUser.isSignedIn && !authUser.isLoading) props.history.push(LOGIN_PATH)
      // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [authUser])
    return authUser ? <Component {...props} /> : null
  })
6reactions
tropicalwhitecommented, Oct 8, 2019

@suyesh Follow https://yarnpkg.com/lang/en/docs/selective-version-resolutions/, Adding this config to your package.json to resolve the issue, I tested and it works

  "resolutions": {
    "react-redux": "^7.1.1"
  },

This config tells redux-token-auth depends on newest react-redux version

Read more comments on GitHub >

github_iconTop Results From Across the Web

When a USPS Text is not a USPS Text
I just received a text from usps regarding a shipment ... I am receiving text messages indicating my scheduled delivery has been changed....
Read more >
Got a package you didn't order? It could be a scam
Sending an item (even the wrong one) creates a tracking number, and when the package is delivered, it enables brushers to write a...
Read more >
Did You Receive a Text Message From Yourself? You're Not ...
Text spam is on the rise. The latest version involves scammers sending messages to you seemingly from your own phone number. Here's what...
Read more >
can't place stone foundation ark
While it too allows strange items as stone or sulfur for Rock Elementals, … ... Upon the top of the ark, probably not...
Read more >
How to Spot and Report Internet and Email Scams
Scams are especially common on the Internet, where new technologies and anonymity ... But there are steps you can take to help stop...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found