-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Private APIs: actions: ensure same function is returned #48937
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
Conversation
|
Size Change: +5 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
|
That's a good catch. It would make sense to include a new test case that covers |
|
Thank you @ellatrix! I agree with the premise. Just pointing out the current implementation breaks a few unit tests. Reviewing this PR in details is on my list, but I didn’t have a chance yet so I’m not sure why these tests break. |
|
Yes, haven't had time to look into the failures yet. |
What?
While debugging performance on typing, I noticed that the actions returned by
unlockare different between each render. So the following is returning false:This is causing an action to be dispatched on every keystroke in
useVisualizer.The solution is to only run
mapActionsonce when the private APIs are registered.I'm not sure if the way I'm doing this is the best. The problem is that private actions are registered after the store in initialised, so we can't map the actions on store init like the regular ones. IMO, it would be better if private actions are registered at the time of store init, but I realise that there's no store ref to use then.
Why?
When using
useEffect, it's important that the action function remains constant.How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast