Skip to content
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

Get state in checkAuth #289

Closed
vmpj opened this issue May 22, 2016 · 4 comments
Closed

Get state in checkAuth #289

vmpj opened this issue May 22, 2016 · 4 comments
Labels

Comments

@vmpj
Copy link

vmpj commented May 22, 2016

Currently in TestReactRouterRedirect a redirect is demonstrated and the state is stubbed.

export default class TestReactRouterRedirect extends BaseComponent {
  static checkAuth(nextState, replace) {
    // Hard code this to demonstrate the effect
    const notAuthorized = true;
    if (notAuthorized) {
      replace({ pathname: '/', state: { redirectFrom: nextState.location.pathname } });
    }
  }

What would be the react-on-rails way to access/get state at this point? I've tried a few approaches with no success. Thanks.

@justin808
Copy link
Member

Hi @vmpj. What sort of state are you looking for?

@vmpj
Copy link
Author

vmpj commented May 23, 2016

Hey @justin808, say I have a bool isLoggedIn stored in some redux store. I'm not exactly sure how to access it.

The solution I got working was based on an implementation using a higher-order component to wrap protected views.

@justin808
Copy link
Member

@vmpj
Copy link
Author

vmpj commented Aug 12, 2016

Thanks @justin808. I'll check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants