Cannot read property 'pathname' of null
RouterのMockを作成せずに、
Material-UIの <Link>
を使うと上記エラーがでる。
その対処法。
.storybook/nextRouterMock.js
import * as nextRouter from 'next/router'
nextRouter.useRouter = () => ({
route: "/",
pathname: "/"
});
nextRouter.router = {
push: () => {},
prefetch: () => new Promise((resolve, reject) => {}),
};
.storybook/config.js
import './nextRouterMock';
参考
https://gist.github.com/novascreen/f1c44ead31e5a494556793be2c408840