mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
We need to handle ref cleanups in a way that is compatible with React 18 and 19. Forking these into -pages (18) and -app (19). Combining them into a single app lead to a different behavior with regards to preload.
25 lines
369 B
JavaScript
25 lines
369 B
JavaScript
'use client'
|
|
import React from 'react'
|
|
import Link from 'next/link'
|
|
|
|
export default () => {
|
|
const myRef = React.createRef(null)
|
|
|
|
React.useEffect(() => {
|
|
if (!myRef.current) {
|
|
console.error(`ref wasn't updated`)
|
|
}
|
|
})
|
|
|
|
return (
|
|
<Link
|
|
href="/"
|
|
ref={(el) => {
|
|
myRef.current = el
|
|
}}
|
|
>
|
|
Click me
|
|
</Link>
|
|
)
|
|
}
|