mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Will be stacked on next React sync which includes `unstable_ViewTransition`. Allows using React's `unstable_ViewTransition` Component behind the `experimental.viewTransition` flag. Right now it just opts into React's experimental build but may later house Next.js specific features like Transition Types for navigations.
27 lines
507 B
JavaScript
27 lines
507 B
JavaScript
'use client'
|
|
import * as React from 'react'
|
|
|
|
export function Toggle() {
|
|
const [show, setShow] = React.useState(false)
|
|
React.useEffect(() => {
|
|
React.startTransition(() => {
|
|
setShow(true)
|
|
})
|
|
}, [])
|
|
|
|
return (
|
|
<div>
|
|
<button
|
|
onClick={() => {
|
|
React.startTransition(() => {
|
|
setShow((show) => !show)
|
|
})
|
|
}}
|
|
>
|
|
{show ? 'A' : 'B'}
|
|
</button>
|
|
{show ? <div>hello</div> : <section>Loading</section>}
|
|
</div>
|
|
)
|
|
}
|