I have a project in material-ui, nextjs and typescript. I’m trying to get my navbar to work with nextjs:
JavaScript
x
15
15
1
import * as React from 'react';
2
import AppBar from '@material-ui/core/AppBar';
3
import Link from "next/link";
4
import {Tab, Tabs} from "@material-ui/core";
5
6
export default function NavBar() {
7
return (
8
<AppBar position="static">
9
<Tabs>
10
<Tab label="Timer"><Link href="timer" /> </Tab>
11
<Tab label="Home" to="/" component={Link} />
12
</Tabs>
13
</AppBar>
14
);
15
}
But it causes the build to fail. Is there something I’m missing?
Advertisement
Answer
In this case, I believe you want to wrap the <Tab />
elements with the <Link />
ones.
JavaScript
1
9
1
<Tabs>
2
<Link href="/timer" passHref>
3
<Tab label="Timer" />
4
</Link>
5
<Link href="/" passHref>
6
<Tab label="Home" />
7
</Link>
8
</Tabs>
9