Files
Sebastian "Sebbie" SilbermannandGitHub 2514e133e7 Add experimental flag for View Transitions (#74659)
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.
2025-01-10 09:49:47 +00:00

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>
)
}