Skip to content

Instantly share code, notes, and snippets.

@pomber
Last active October 28, 2019 22:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Maybe some day we'll have something like this
function App({ items }) {
const [itemId, setItemId] = useState(null)
const [startTransition, prepareTransition] = useTransition(newId => setItemId(newId), {
timeoutMs: 1000
})
return (
<Suspense fallback='Loading...'>
{itemId === null ? (
<ul>
{items.map(item => (
<li
onMouseEnter={() => prepareTransition(item.id)}
onClick={() => startTransition(item.id)}
children={item.name}
/>
))}
</ul>
) : (
<ItemPage id={itemId} />
)}
</Suspense>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment