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

Authenticate component renders on each redux state change #41

Open
alexyuly opened this issue Apr 19, 2017 · 0 comments
Open

Authenticate component renders on each redux state change #41

alexyuly opened this issue Apr 19, 2017 · 0 comments

Comments

@alexyuly
Copy link

I'm using the Authenticate component in an app that uses React and Redux. Using the React Perf add-on, I found that my instance of this component was rendering on each and every Redux state change, causing a lot of wasted rendering time (since my app has very frequent state changes).

After some investigation, I found that this occurs because Authenticate subscribes to accounts.instance.store (see https://github.com/js-accounts/react/blob/master/packages/react/src/authenticate.js#L25). In my use case, I was passing my app's Redux store into AccountsClient.config (when initializing the overall accounts package), which resulted in Authenticate subscribing to my app's Redux store.

I fixed my problem by not passing in my app's Redux store to AccountsClient.config, which allows accounts to use its own default, private Redux store. However, this may not be a practical solution for all users. I would recommend that Authenticate is modified so that it does not render on each and every state change -- only those state changes that are relevant, to avoid wasted rendering.

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