react-three-fiber
react-three-fiber copied to clipboard
Allow pass custom store by props
Currently there is no way to access the store outside the canvas context for some applications is usefull to have access to the canvas store outside its context for get scene graph, get stats or manage the event loop outside the canvas context (ie pause, advance nframes etc...)
This is very internal to R3F, so we can't open this up as a prop, such as in #3179. I would instead propose hoisting up references to state methods via context or the get() callback from useThree(). Ideally, state will propogate downwards, which prevents bugs in the long run and encourages the component encapsulation model of React -- you should be able to unmount components and their effects remain side-effect free. If you must hold a reference to the store, such as for subscriptions, you can get a handle over the Zustand store via useStore().