-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using generateRequireSignInWrapper throws error #53
Comments
@Rinbo Did you get this working? |
@suyesh nope. |
@rinboi tried everything and nothing worked. Going to good old create from scratch mode. |
@suyesh Yeah, same here. |
@Rinbo I would need your advice on how to solve this issue. |
@tochman I threw out this module and implemented my own middleware instead:
Then I applied it to store in root index.js:
Then in authActions i made the following function:
The setHeaders function just relays the headers that gets returned from the rails app to the middleware (via the action key), so that they are always available to the axios module (needed for every request). Then you can make your own custom protected routes (assuming you are using react-router-dom), in which I call the validateUser action in ComponentDidMount. For my part I made three custom routes. AdminRoute, ProtectedRoute (for signed in users) and AuthRoute (which automatically redirects a signed in user away from the signup page). The syntax is a little obscure but here is the ProtectedRoute.js:
You can probably omit IsDOMLoaded. Don't remember why I included that. Then in your app.js where you define your routes:
|
Awesome solution. |
Using the generateRequireSignInWrapper gives me this error message:
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)".
Here is my code:
index.js
app.js
The text was updated successfully, but these errors were encountered: