标签 nextjs 下的文章

  1. It is rendered once on the server - it is the root of your app
  2. App's getInitialProps is called before anything else - even before getInitialProps in _document.js
  3. It is created and mounted ONLY ONCE on the client - when the page first loads. Thereafter, on page navigation, App.getInitialProps is called before each page, and then its render function is called, to render the incoming page.

- 阅读剩余部分 -

首先,Next.js是个好学校,啊不,是个好框架;
其次,Next.js的文档也不算烂,但确实有点简陋,好多都是undocumented

Next.js有个feature叫做file-system routing:

By default, Next will serve each file in /pages under a pathname matching the filename (eg, /pages/some-file.js is served at site.com/some-file.

你可以设置一个option来turn it off:

// next.config.js
module.exports = {
  useFileSystemPublicRoutes: false,
}

我今天谈论的重点是这个问题:当我在Components/SomeComponenet.jsx里使用router(不论是useRouter还是withRouter),都会报错,错误信息这样的:

- 阅读剩余部分 -