URL State with React Router 6 and Search Params

  • Now, having felt the pain first hand (including this particular library) and after a few years of react coding here is my tip for you, the aspiring web react developer:

    Do not directly use library code in your react components, such as react-router (unless your top level route definitions of course).

    Let your react components consume data given in their parameters, let them be oblivious to how you got that data. If you have to use a library hook, wrap that hook in your own hook and write a unit test for your custom hook because I promise you, the library hook will break in a version upgrade. I reapeat: the library hook WILL break in a future version upgrade

    :)