Skip to content

Instantly share code, notes, and snippets.

@pomber
Last active Oct 28, 2019
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