If you work on a large project not using an HOC for layout will be a huge pain. The connect function was indeed replaced with hooks, but you would still need the withRouter HOC for quite a few cases
We both have different viewpoints. So, let's agree to disagree :)
Am I wrong in understanding that Everytime you use HOC those components (nav, footer, ...) will be mounted and remounted?? I think better layout way is router and lazy loading, right? Or as said Hooks and Context.
The beauty of react-router is to nest as many switches as you need. And I so far haven't found an use for withRouter since useHistory and other hooks are available.
The purpose of a separate layout would be to keep the routing logic separate from the ui logic. But you are correct about the re-rendering of the components.
I have used useHistory for only navigation, so I don't have enough knowledge to comment on how it compares to withRouter
Thanks for your input :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In 99% cases - hooks.
You can check also this post, if you really want to know:
medium.com/javascript-scene/do-rea...
Yes, HOC can be used, but only in niche scenarios that you won't encounter super often.
If you work on a large project not using an HOC for layout will be a huge pain. The
connect
function was indeed replaced with hooks, but you would still need thewithRouter
HOC for quite a few casesWe both have different viewpoints. So, let's agree to disagree :)
Am I wrong in understanding that Everytime you use HOC those components (nav, footer, ...) will be mounted and remounted?? I think better layout way is router and lazy loading, right? Or as said Hooks and Context.
The beauty of react-router is to nest as many switches as you need. And I so far haven't found an use for withRouter since useHistory and other hooks are available.
The purpose of a separate layout would be to keep the routing logic separate from the ui logic. But you are correct about the re-rendering of the components.
I have used useHistory for only navigation, so I don't have enough knowledge to comment on how it compares to withRouter
Thanks for your input :)