Skip to content
Discussion options

You must be logged in to vote

Think of params as state. It's generally an anti-pattern to duplicate state to two places.

It may be convenient to pass route.params in initialParams, but it comes with many downsides:

  • When the parent route.params updates, the tab screens won't get new params because initialParams is applied on initial render, so you'll need to write more code to handle this, which negates the convenience
  • This pattern makes it possible for each tab to have different IDs which can also differ from the ID in parent params. This can be desirable behavior, but if not, having "impossible state" is generally bad as it adds more edge cases and conditions to test. It's best to design the logic in a way to "make …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JosephLu2022
Comment options

Answer selected by JosephLu2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants