File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/components/concurrent Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { unstable_scheduleCallback } from 'scheduler';
3
3
4
4
const LargeList = ( { remainder } ) => {
5
5
return < ul >
6
- { [ ...Array ( 2000 ) . keys ( ) ] . map ( ( n ) => {
6
+ { [ ...Array ( 2000 ) . keys ( ) ] . map ( n => {
7
7
return ( remainder === n % 2 ) && < li key = { n } > { n } </ li > ;
8
8
} ) }
9
9
</ ul > ;
@@ -13,6 +13,8 @@ function Concurrent2() {
13
13
const [ query , setQuery ] = useState ( '' ) ;
14
14
const [ remainder , setRemainder ] = useState ( 0 ) ;
15
15
16
+ const mode = window . localStorage . getItem ( 'mode' ) ;
17
+
16
18
return < div >
17
19
< input
18
20
type = "text"
@@ -21,9 +23,14 @@ function Concurrent2() {
21
23
const value = e . target . value ;
22
24
const remainder = value . length % 2 ;
23
25
setQuery ( value ) ;
24
- unstable_scheduleCallback ( ( ) => {
26
+
27
+ if ( mode === 'concurrent' ) {
28
+ unstable_scheduleCallback ( ( ) => {
29
+ setRemainder ( remainder ) ;
30
+ } ) ;
31
+ } else {
25
32
setRemainder ( remainder ) ;
26
- } )
33
+ }
27
34
} }
28
35
/> { ' ' } { query . length }
29
36
< LargeList remainder = { remainder } />
You can’t perform that action at this time.
0 commit comments