Open astahmer opened 2 years ago
+1 This would also enable you to create multiple stores upfront and use the correct one depending on the App state, i.e.
const stores = useMemo(() => myList.map(() => new Store()), [myList]) ;
return <LevaPanel store={stores[index]} />
Right now this requires another wrapper component, since you can't call useCreateStore in a loop.
Hey, I was trying to auto-sync an atom (from jotai) with the results of useControls (so that I can access it anywhere) So I thought of using the jotai/zustand util atomWithStore and by passing a custom leva store to useControls The thing is, the only way to create a custom leva store right now is from the useCreateStore hook
Could you export the Store class or a new createStore function ? We would also need the getValuesForPaths utils exported to get the same output as useControls
Then we would be able to do something like
This would maybe also make persistence (#133) possible using
atomWithStorage
?