NextJS 13 / Zustand - Sharing a Single Spring Across Components #2127
Unanswered
JS-GitRepo
asked this question in
Support
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am currently migrating my portfolio website to Next JS / Zustand from an SPA / React-Context architecture. The main issue I am having is sharing a single spring across many files without the use of React Context.
In short, I have a simple filter animation that constantly rotates the hue of highlighted text (and images) throughout my website. Previously I used Context for this, but had issues where the spring would die randomly and thought transitioning to some other form of state management might help and I was already eyeing a switch from an SPA to NextJS. In trying to do this, I found I can't store a hook outside of a React component, and I can't seem to update my Zustand store with a spring that is living inside of a component without crashing / terrible performance issues (presumably because it is constantly updating the store as the spring value is changing.)
Any ideas for sharing one spring across many components without the use of Context and prop drilling? I can go back to Context if that is my only option but am curious to see if anyone here has more creative solutions, or if there is an alternate way to use springs that I am missing. Thank you all for your time!
Beta Was this translation helpful? Give feedback.
All reactions