I am trying to use correctly hooks with a 3d scene widget. I really don't understand how to deal with component variables
A 3d scene is created in useEffect() , that is fired only once. Some component variables are created , like scene, camera , camera controls inside useEffect()
I will later need some references to these variable , camera or camera controls variable (eg, to zoom thanks an ui slider).
in this component example, a zoom value is changed thanks to an external zoom ui slider ,
I can retrieve the zoom value thanks to redux store .
I am notified of this change with useMemo zoomChanged function .
first question : why zoomChanged does not work with a useCallback instead of useMemo ????
second question, how can I access to component variables controls or camera inside zoomChanged function ? they are undefined when zoomChanged is fired.
I am trying to use correctly hooks with a 3d scene widget. I really don't understand how to deal with component variables
A 3d scene is created in useEffect() , that is fired only once. Some component variables are created , like scene, camera , camera controls inside useEffect() I will later need some references to these variable , camera or camera controls variable (eg, to zoom thanks an ui slider).
in this component example, a zoom value is changed thanks to an external zoom ui slider , I can retrieve the zoom value thanks to redux store .
I am notified of this change with useMemo zoomChanged function . first question : why zoomChanged does not work with a useCallback instead of useMemo ????
second question, how can I access to component variables controls or camera inside zoomChanged function ? they are undefined when zoomChanged is fired.