提交 144eecd1 编写于 作者: J JJ Kasper 提交者: Joe Haddad

Add example with forwardRef to readme (#8428)

上级 37c66697
......@@ -585,6 +585,29 @@ export default About
Note: if passing a functional component as a child of `<Link>` you will need to wrap it in [`React.forwardRef`](https://reactjs.org/docs/react-api.html#reactforwardref)
**Example with `React.forwardRef`**
```jsx
import React from 'react'
import Link from 'next/link'
// `onClick`, `href`, and `ref` need to be passed to the DOM element
// for proper handling
const MyButton = React.forwardRef(({ onClick, href }, ref) => (
<a href={href} onClick={onClick} ref={ref}>
Click Me
</a>
))
export default () => (
<>
<Link href='/another'>
<MyButton />
</Link>
</>
)
```
**Custom routes (using props from URL)**
If you find that your use case is not covered by [Dynamic Routing](#dynamic-routing) then you can create a custom server and manually add dynamic routes.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册