flexpool / frontend

Source code of the v2 Flexpool.io Website
https://flexpool.io
GNU Affero General Public License v3.0
65 stars 37 forks source link

Update query parameter handle logic #391

Open aminick opened 3 years ago

aminick commented 3 years ago

Through out the application, there are many situations where the UI will respond to the query parameter both on initial load, and sub-sequence re-renders, however, the current query parameter handle logic has a few flaws that can be error prone and hard to debug.

  1. Extra '/' in the URL Screen Shot 2021-08-21 at 17 20 03

This will cause Next.js's router system unable to correctly get query parameters, which makes the built in & recommend method router.query obsolete

  1. Using default Popstate is error prone Screen Shot 2021-08-21 at 20 05 44

Using the default Popstate leaves inconsistancy behaviors across browsers and will trigger unexpected re-render.

I will be slowly migrate to a more robust system, utilize Next.js API and React hooks.

aminick commented 3 years ago

Some of the current query parameter parse logic is incompatible with SSR/SGR. A lot of times, we only have the parse logic in hooks, but not in getStaticProps and other server side functions. This results in inconsistent results between the URL & the SSR content, which in rare cases, will cause unexpected rendering issues.