Skip to content

Avoid allocating a redundant function in the Provider #1857

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

Closed
wants to merge 1 commit into from

Conversation

Andarist
Copy link
Contributor

No description provided.

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit b1d058c:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration

@netlify
Copy link

netlify bot commented Dec 23, 2021

✔️ Deploy Preview for react-redux-docs ready!

🔨 Explore the source changes: b1d058c

🔍 Inspect the deploy log: https://app.netlify.com/sites/react-redux-docs/deploys/61c453616c5415000a6f3df4

😎 Browse the preview: https://deploy-preview-1857--react-redux-docs.netlify.app

@@ -39,7 +39,7 @@ function Provider<A extends Action = AnyAction>({
}
}, [store, serverState])

const previousState = useMemo(() => store.getState(), [store])
const previousState = useMemo(store.getState, [store])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that it breaks custom stores that rely on this. A test covering this use case was originally introduced here and fixed this issue

Given how rare of a use case this is and the allocation cost that this requires for all users I would say that it would be better to drop support for this use case and require users who need this to bind their stores appropriately. It's an easy thing to do and feels to me like something that can be easily handled in the userland.

OTOH Provider itself is, at least currently, usually not rendered often as it lives "on the top" of the app. So kinda 🤷

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically Provider is only ever going to render once in an app anyway. Given that, I'm not sure this change really provides any benefit :)

@markerikson
Copy link
Contributor

I'm gonna pass on this one. I can see the argument for dropping a meaningless use case, but also I don't think there's enough actual benefit here to justify the change.

@Andarist
Copy link
Contributor Author

Fine by me 👍

@Andarist Andarist deleted the patch-1 branch December 23, 2021 17:46
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

Successfully merging this pull request may close these issues.

2 participants