How would you store a ref of an external packages in a state (useState)
I have this:
handleSubmit
is a method and messages
is a ref()
.
How can I wrap this in useState
to be able to call handleSubmit
and access messages from any component and keep the state alive on route change?3 Replies
is it necessary to be
useState
? As in - do you render it on the server?Not really, I only want the chat messages / methods etc available across multiple pages/components
Currently I do:
But I should do it manually for each item and it's not ideal to keep all duplicated and synced. Ideally I would just have the messages directly in a store
@manniL / TheAlexLichter
But it's definitely only needed client side if that simplifies things
if it is client-only, then use a composable with a ref outside of the function. just make sure this is never called on the server