mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Update README.md
This commit is contained in:
parent
4e77e105af
commit
e9543cf614
19
README.md
19
README.md
|
@ -214,16 +214,14 @@ Most needs are addressed by `<Link />`, but we also expose an imperative API for
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
import { prefetch } from 'next/prefetch'
|
import { prefetch } from 'next/prefetch'
|
||||||
prefetch('/')
|
export default ({ url }) => (
|
||||||
prefetch('/features')
|
<a onClick={ () => setTimeout(() => url.pushTo('/dynamic'), 100) }>
|
||||||
```
|
A route transition will happen after 100ms
|
||||||
|
</a>
|
||||||
Note: it's also possible to prefetch by using an empty `<Link />`:
|
{
|
||||||
|
// but we can prefetch it!
|
||||||
```js
|
prefetch('/dynamic')
|
||||||
import Link from 'next/prefetch'
|
}
|
||||||
export default () => (
|
|
||||||
<div>Hello world <Link href="/prefetch-this" /></div>
|
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -233,7 +231,6 @@ export default () => (
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
export default class Error extends React.Component {
|
export default class Error extends React.Component {
|
||||||
static getInitialProps ({ res, xhr }) {
|
static getInitialProps ({ res, xhr }) {
|
||||||
const statusCode = res ? res.statusCode : (xhr ? xhr.status : null)
|
const statusCode = res ? res.statusCode : (xhr ? xhr.status : null)
|
||||||
|
|
Loading…
Reference in a new issue