Skip to content

Commit 1b17b55

Browse files
authored
Add router to provider in Next.js example (#5159)
1 parent c4ef4b2 commit 1b17b55

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

examples/rsp-next-ts/pages/_app.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@ import Moon from "@spectrum-icons/workflow/Moon";
1414
import Light from "@spectrum-icons/workflow/Light";
1515
import { ToastContainer } from "@react-spectrum/toast";
1616
import {enableTableNestedRows} from '@react-stately/flags';
17+
import {useRouter} from 'next/router';
1718

1819
function MyApp({ Component, pageProps }: AppProps) {
1920
const [theme, setTheme] = useState<ColorScheme>("light");
2021

22+
let router = useRouter();
2123
let themeIcons = { dark: <Moon />, light: <Light /> };
2224
let otherTheme: ColorScheme = theme === "light" ? "dark" : "light";
2325
enableTableNestedRows();
2426

2527
return (
26-
<Provider theme={lightTheme} colorScheme={theme}>
28+
<Provider theme={lightTheme} colorScheme={theme} router={{navigate: router.push}}>
2729
<Grid
2830
areas={["header", "content"]}
2931
columns={["1fr"]}

examples/rsp-next-ts/pages/foo.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Foo() {
2+
return <h1>Foo</h1>;
3+
}

examples/rsp-next-ts/pages/index.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export default function Home() {
167167
<MenuTrigger>
168168
<ActionButton>Menu Trigger</ActionButton>
169169
<Menu>
170+
<Item href="/foo">Link to /foo</Item>
170171
<Item>Cut</Item>
171172
<Item>Copy</Item>
172173
<Item>Paste</Item>
@@ -268,15 +269,13 @@ export default function Home() {
268269
<Item key="march 2020 assets">March 2020 Assets</Item>
269270
</Breadcrumbs>
270271

271-
<Link>
272-
<a
273-
href="https://www.imdb.com/title/tt6348138/"
274-
target="_blank"
275-
rel="noreferrer"
276-
>
277-
The missing link.
278-
</a>
272+
<Link
273+
href="https://www.imdb.com/title/tt6348138/"
274+
target="_blank"
275+
rel="noreferrer">
276+
The missing link.
279277
</Link>
278+
<Link href="/foo">Foo</Link>
280279

281280
<Tabs aria-label="History of Ancient Rome">
282281
<TabList>

0 commit comments

Comments
 (0)