3DStreet / 3dstreet-editor

3DStreet Editor Repo
https://3dstreet.app
Other
18 stars 3 forks source link

Is beta checking #428

Closed Algorush closed 2 months ago

Algorush commented 2 months ago

I needed to wrap the Main class in a functional component, since the useAuthContext required to obtain user data only works inside functional components. Perhaps there is another solution, I'm not good at react

vincentfretin commented 2 months ago

Creating a functional component MainWrapper was the right call for the immediate need I think. You indeed can't use hooks inside a class component. You can of course convert the Main class component to a functional component, but you need to be extra careful with using useCallback everywhere and modify the setState calls to include the prev state, otherwise you can easily have regressions. In a project, I converted all class components to functional components to be able to use the useIntl hook. Some components ended up being really more complex in my opinion compared to the class implementation where I had lots of effects.