Skip to content

Commit

Permalink
do not use defer in sync mode
Browse files Browse the repository at this point in the history
  • Loading branch information
latviancoder committed Jan 11, 2019
1 parent 07cf789 commit daf25bf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/concurrent/Concurrent2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { unstable_scheduleCallback } from 'scheduler';

const LargeList = ({ remainder }) => {
return <ul>
{[...Array(2000).keys()].map((n) => {
{[...Array(2000).keys()].map(n => {
return (remainder === n % 2) && <li key={n}>{n}</li>;
})}
</ul>;
Expand All @@ -13,6 +13,8 @@ function Concurrent2() {
const [query, setQuery] = useState('');
const [remainder, setRemainder] = useState(0);

const mode = window.localStorage.getItem('mode');

return <div>
<input
type="text"
Expand All @@ -21,9 +23,14 @@ function Concurrent2() {
const value = e.target.value;
const remainder = value.length % 2;
setQuery(value);
unstable_scheduleCallback(() => {

if (mode === 'concurrent') {
unstable_scheduleCallback(() => {
setRemainder(remainder);
});
} else {
setRemainder(remainder);
})
}
}}
/>{' '}{query.length}
<LargeList remainder={remainder}/>
Expand Down

0 comments on commit daf25bf

Please sign in to comment.