Closed Algorush closed 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.
I needed to wrap the
Main
class in a functional component, since theuseAuthContext
required to obtain user data only works inside functional components. Perhaps there is another solution, I'm not good at react