Skip to content

Instantly share code, notes, and snippets.

@pomber
Last active October 28, 2019 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pomber/358bfcde662168e5a9728ca4fa1ac051 to your computer and use it in GitHub Desktop.
Save pomber/358bfcde662168e5a9728ca4fa1ac051 to your computer and use it in GitHub Desktop.
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