generated from chiffre-io/template-library
-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use correct keys for state sync (#759)
Closes #758.
- Loading branch information
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/// <reference types="cypress" /> | ||
|
||
describe('repro-758', () => { | ||
it('honors urlKeys when navigating back after a push', () => { | ||
cy.visit('/app/repro-758') | ||
cy.contains('#hydration-marker', 'hydrated').should('be.hidden') | ||
cy.get('button').click() | ||
cy.get('#state').should('have.text', 'test') | ||
cy.go('back') | ||
cy.get('#state').should('be.empty') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use client' | ||
|
||
import { parseAsString, useQueryStates } from 'nuqs' | ||
import { Suspense } from 'react' | ||
|
||
export default function Page() { | ||
return ( | ||
<Suspense> | ||
<Client /> | ||
</Suspense> | ||
) | ||
} | ||
|
||
function Client() { | ||
const [{ query }, setSearchParams] = useQueryStates( | ||
{ | ||
query: parseAsString | ||
}, | ||
{ | ||
history: 'push', | ||
urlKeys: { | ||
query: 'q' | ||
} | ||
} | ||
) | ||
return ( | ||
<> | ||
<button onClick={() => setSearchParams({ query: 'test' })}> | ||
Set query | ||
</button> | ||
<p id="state">{query}</p> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters