-
Notifications
You must be signed in to change notification settings - Fork 2
fix: update ensemble storage #1061
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
base: main
Are you sure you want to change the base?
Conversation
|
Visit the preview URL for this PR (updated for commit 81bdc35): https://react-kitchen-sink-dev--pr1061-update-storage-465y6khg.web.app (expires Tue, 01 Apr 2025 13:23:53 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 6267897ade2ba783b6db70a53a60fc3946d625e9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what the issue is? This change will add a lot of extra renders.
const storage = useEnsembleStorage(); | ||
|
||
return useAtomCallback( | ||
useCallback( | ||
(get, set, ...args: T) => { | ||
const applicationContext = get(appAtom); | ||
const screenContext = get(screenAtom); | ||
const storage = get(screenStorageAtom); | ||
const device = get(deviceAtom); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not right - the reason we use get
instead of the hook here is to prevent unnecessary re-renders whenever the storage is changed.
() => createStorageApi(storageBuffer, setStorage), | ||
[setStorage, storageBuffer], | ||
); | ||
const storageApi = createStorageApi(storage, setStorage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do?
Describe your changes
update ensemble storage to share the values on multiple screens
Screenshots [Optional]
Before:
Screen.Recording.2025-03-25.at.7.02.02.PM.mp4
After:
Screen.Recording.2025-03-25.at.6.53.44.PM.mp4
Issue ticket number and link
Closes #
Checklist before requesting a review
pnpm changeset add