Files
react/shells/dev/app/PriorityLevels/index.js
T
2019-05-20 09:39:26 -07:00

30 lines
671 B
JavaScript

// @flow
import React, { Fragment, useCallback, useState } from 'react';
import { unstable_next as next } from 'scheduler';
export default function PriorityLevels() {
const [count, setCount] = useState(0);
const startSequence = useCallback(() => {
setCount(1);
next(() => setCount(2));
}, []);
return (
<Fragment>
<h1>Priority Levels</h1>
<button onClick={startSequence}>start sequence</button>
{count >= 1 && <Text>One</Text>}
{count >= 2 && <Text>Two</Text>}
{count >= 2 && (
<div hidden>
<Text>Three</Text>
</div>
)}
</Fragment>
);
}
const Text = ({ children }) => children;