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

How to detect current user synchronously? #69

Open
joncursi opened this issue Jun 21, 2017 · 2 comments
Open

How to detect current user synchronously? #69

joncursi opened this issue Jun 21, 2017 · 2 comments

Comments

@joncursi
Copy link

In my render function, I want to render a View depending on whether or not the user is signed in or not. You can do this synchronously via:

{currentUser &&
  <View>
    {...}
  </View>
}

How do you achieve this with meteor-apollo-accounts? The only thing I can find is userId, but that is an async value so it doesn't work in the above example. Thanks!

@joncursi
Copy link
Author

The same goes for fetching data. In many components, I need to fetch data if there is a user signed in. However, if there is no user, I shouldn't fetch the data. However, again, recompose HOCs do not support async for good reasons.

@joncursi
Copy link
Author

I'm not sure if this is the recommended way to do this, but my workaround for now is to store the tokens myself to my own Redux store:

    onTokenChange((tokenData) => {
      dispatch({
        payload: tokenData,
        type: UPDATE_USER,
      });
    });

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

No branches or pull requests

1 participant