You can try to move to functional components instead. You will not get rid of JSX but it will certainly resolve some issues that you listed:
this
Will not be a problem anymore
Nested states
I had another problem here. Not as the fact that it doesn't work, you can have nested states as you specified. The problem wast that render was not triggered on the nested changes... the component does not render again due to the fact that it checks only the first level of the state object, it's not a deep comparison.
With hooks you can split the nested object to multiple objects and have only one level.
You can also go further and wrap the content in a useMemo hook to not create it every time but only if isLogged has changed...
There a lot of ways of going on with this... I think that going to functional with hooks solves some issues, of course everybody have their own opinion, this is just mine on this case.
Hi
All these things you mentioned are amazing and thanks for sharing these with me.
But still I believe these are ways to workaround and still very complicated than other frameworks like Vue.
You can try to move to functional components instead. You will not get rid of JSX but it will certainly resolve some issues that you listed:
this
Will not be a problem anymore
Nested states
I had another problem here. Not as the fact that it doesn't work, you can have nested states as you specified. The problem wast that render was not triggered on the nested changes... the component does not render again due to the fact that it checks only the first level of the
stateobject, it's not a deep comparison.With hooks you can split the nested object to multiple objects and have only one level.
JSX
Conditional rendering... you can have conditional rendering in multiple ways done, it's just a matter of choice
either just put the conditional in the render function
either create a separate conditional and use it in the render
You can also go further and wrap the content in a
useMemohook to not create it every time but only ifisLoggedhas changed...There a lot of ways of going on with this... I think that going to functional with hooks solves some issues, of course everybody have their own opinion, this is just mine on this case.
Hi
All these things you mentioned are amazing and thanks for sharing these with me.
But still I believe these are ways to workaround and still very complicated than other frameworks like Vue.
I suggest you read this:
How is it like to work with GatsbyJS as a Nuxt.js developer?
Adnan Babakan (he/him) ・ Nov 8 '19 ・ 6 min read