-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: reinstantiate state parameter for goto #11342
Conversation
🦋 Changeset detectedLatest commit: 4728a54 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems preferable to me than having the user make two calls. This is more atomic than having it in an undesirable state in between the two calls
Are there 1.x deprecation warnings that need to be removed as well or anything in the migration tool?
I'm not sure about this — it's pretty weird to keep an API but change its behaviour. If you do this... await goto(...);
replaceState('', state); ...then there's no undesirable in-between state |
There will be a tick in which the page state is empty and it's updated to being a state afterwards. It's different from being set immediately. |
Another argument for this: Preserving state across a navigation. This is a lot more awkward than it was prior to 2.x
vs
If context helps, the page has three different tabs. Each tab has its own url and load function. The tabs are styled using material design so creating navigation history would be surprising. |
This reinstantiates the
state
parameter for theoptions
argument togoto
. In the original shallow routing PR, this was mentioned as the alternative, and it may make sense to do it this way instead of requiring people to doawait goto(..); replaceState({ ..})
instead of justgoto(..., { state: { .. } })
. It also means the page store is updated directly, and doesn't have a tick were it's empty.Open for debate if we really want to do this, but the change itself is rather easy so I thought I'd open the PR. Probably needs a test if we reinstantiate.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.