#Best practice for reloading a page based on user inputs

1 messages · Page 1 of 1 (latest)

twin spade
#

Hi, I have a page that displays data from a separate API. The user can change parameters such as date range and which data to include using UI in a form on the page. What is the best practice for state such as the date range? I default it in the initial loader. I can change it using the Form with an action on my page, but when the loader is called again, won't the date range be reset to the default by the loader? I don't need/want to persist these settings in a database. What is the Remix idiom for doing this? Should I be using URL parameters for this? useFetcher.data?

limpid fiber
#

The trick is getting the parameters to your loaders somehow so they can load the correct data. Your options are:

  • URL Params
  • Put it in a cookie (not even a session cookie)
  • Manually store the data client-side and send it with useFetcher requests

There might be more, but URL params seem the neatest.