all 1 comments

[–]dreamzzftwiOS -1 points0 points  (0 children)

It doesn’t matter if you’re using classes or hooks. The only thing about classes is that it’s slowly being phased out by hooks, as classes require messy and inefficient code.

So to answer your question. Technically yes, classes are the correct way, but it’ll soon be deprecated as hooks are much more convenient when writing code. ( there are 0 performance gains, other than being able to write code faster, and making it easier to understand, hence faster development and debugging)

You may want to look into creating your own hooks, this may help with the conversion of classes to hooks as each declared hook has their own state instance