1
- import React , { Component , PureComponent , unstable_AsyncMode } from 'react' ;
1
+ import React , { PureComponent , unstable_AsyncMode } from 'react' ;
2
2
import { flushSync , render , unstable_deferredUpdates } from 'react-dom' ;
3
3
import _ from 'lodash' ;
4
4
import Charts from './Charts' ;
@@ -64,9 +64,12 @@ class App extends PureComponent {
64
64
}
65
65
this . _ignoreClick = true ;
66
66
67
- unstable_deferredUpdates ( ( ) => {
68
- this . setState ( { showDemo : true } , ( ) => {
69
- this . _ignoreClick = false ;
67
+ // TODO: needing setTimeout here seems like a React bug.
68
+ setTimeout ( ( ) => {
69
+ unstable_deferredUpdates ( ( ) => {
70
+ this . setState ( { showDemo : true } , ( ) => {
71
+ this . _ignoreClick = false ;
72
+ } ) ;
70
73
} ) ;
71
74
} ) ;
72
75
} ;
@@ -79,15 +82,13 @@ class App extends PureComponent {
79
82
}
80
83
} , 1000 ) ;
81
84
82
- renderOption ( strategy , label , enabled ) {
85
+ renderOption ( strategy , label ) {
83
86
const { strategy : currentStrategy } = this . state ;
84
87
return (
85
88
< label
86
- className = { strategy === currentStrategy ? 'selected' : null }
87
- style = { { opacity : enabled ? 1 : 0.5 } } >
89
+ className = { strategy === currentStrategy ? 'selected' : null } >
88
90
< input
89
91
type = "radio"
90
- disabled = { ! enabled }
91
92
checked = { strategy === currentStrategy }
92
93
onChange = { ( ) => this . setState ( { strategy} ) }
93
94
/>
@@ -107,8 +108,11 @@ class App extends PureComponent {
107
108
this . debouncedHandleChange ( value ) ;
108
109
break ;
109
110
case 'async' :
110
- unstable_deferredUpdates ( ( ) => {
111
- this . setState ( { value} ) ;
111
+ // TODO: needing setTimeout here seems like a React bug.
112
+ setTimeout ( ( ) => {
113
+ unstable_deferredUpdates ( ( ) => {
114
+ this . setState ( { value} ) ;
115
+ } ) ;
112
116
} ) ;
113
117
break ;
114
118
default :
@@ -124,13 +128,9 @@ class App extends PureComponent {
124
128
return (
125
129
< div className = "container" >
126
130
< div className = "rendering" >
127
- { this . renderOption ( 'sync' , 'Synchronous' , true ) }
128
- { this . renderOption ( 'debounced' , 'Debounced' , true ) }
129
- { this . renderOption (
130
- 'async' ,
131
- 'Asynchronous' ,
132
- false
133
- ) /* TODO Fix async demo and re-enable */ }
131
+ { this . renderOption ( 'sync' , 'Synchronous' ) }
132
+ { this . renderOption ( 'debounced' , 'Debounced' ) }
133
+ { this . renderOption ( 'async' , 'Asynchronous' ) }
134
134
</ div >
135
135
< input
136
136
className = { 'input ' + this . state . strategy }
0 commit comments