generated from chiffre-io/template-library
-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
102 additions
and
17 deletions.
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
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
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
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 |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import { NuqsAdapter } from 'nuqs/adapters/react' | ||
import { StrictMode } from 'react' | ||
import { createRoot } from 'react-dom/client' | ||
import App from './App.tsx' | ||
import { ReactRouter } from './react-router' | ||
import { VanillaReact } from './vanilla-react' | ||
|
||
createRoot(document.getElementById('root')!).render( | ||
createRoot(document.getElementById('root-vanilla')!).render( | ||
<StrictMode> | ||
<NuqsAdapter> | ||
<App /> | ||
</NuqsAdapter> | ||
<VanillaReact /> | ||
</StrictMode> | ||
) | ||
|
||
createRoot(document.getElementById('root-react-router')!).render( | ||
<StrictMode> | ||
<ReactRouter /> | ||
</StrictMode> | ||
) |
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,18 @@ | ||
import { NuqsAdapter } from 'nuqs/adapters/react-router' | ||
import { createBrowserRouter, RouterProvider } from 'react-router-dom' | ||
import App from './App' | ||
|
||
const router = createBrowserRouter([ | ||
{ | ||
path: '/', | ||
element: <App router="React Router" /> | ||
} | ||
]) | ||
|
||
export function ReactRouter() { | ||
return ( | ||
<NuqsAdapter> | ||
<RouterProvider router={router} /> | ||
</NuqsAdapter> | ||
) | ||
} |
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,10 @@ | ||
import { NuqsAdapter } from 'nuqs/adapters/react' | ||
import App from './App' | ||
|
||
export function VanillaReact() { | ||
return ( | ||
<NuqsAdapter> | ||
<App router="Vite + React" /> | ||
</NuqsAdapter> | ||
) | ||
} |
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,7 @@ | ||
// This file is needed for projects that have `moduleResolution` set to `node` | ||
// in their tsconfig.json to be able to `import {} from 'nuqs/adapters/react-router'`. | ||
// Other module resolutions strategies will look for the `exports` in `package.json`, | ||
// but with `node`, TypeScript will look for a .d.ts file with that name at the | ||
// root of the package. | ||
|
||
export * from '../dist/adapters/react-router' |
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
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,19 @@ | ||
import { useSearchParams } from 'react-router-dom' | ||
import type { AdapterOptions } from './defs' | ||
import { createAdapterProvider } from './internal.context' | ||
|
||
function useNuqsReactRouterAdapter() { | ||
const [searchParams, setSearchParams] = useSearchParams() | ||
const updateUrl = (search: URLSearchParams, options: AdapterOptions) => { | ||
setSearchParams(search, { | ||
replace: options.history === 'replace', | ||
preventScrollReset: !options.scroll | ||
}) | ||
} | ||
return { | ||
searchParams, | ||
updateUrl | ||
} | ||
} | ||
|
||
export const NuqsAdapter = createAdapterProvider(useNuqsReactRouterAdapter) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.