File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,15 @@ const html = htm.bind(h);
6
6
7
7
// configuration used to show behavior vs. workaround
8
8
let childFirst = true ;
9
+ const Config = ( ) => html `< label >
10
+ < input type ="checkbox "
11
+ checked =${ childFirst }
12
+ onchange =${ evt => {
13
+ childFirst = evt . target . checked ;
14
+ } }
15
+ />
16
+ Set child state before parent state.
17
+ </ label > ` ;
9
18
10
19
const Child = ( { items, setItems } ) => {
11
20
let [ pendingId , setPendingId ] = useState ( null ) ;
@@ -46,7 +55,7 @@ const Child = ({ items,setItems }) => {
46
55
47
56
const Parent = ( ) => {
48
57
let [ items , setItems ] = useState ( [ ] ) ;
49
- return html `< div > < ${ Child } items =${ items } setItems=${ setItems } /> </ div > ` ;
58
+ return html `< div > < ${ Config } /> < ${ Child } items =${ items } setItems=${ setItems } /> </ div > ` ;
50
59
} ;
51
60
52
61
export default Parent ;
You can’t perform that action at this time.
0 commit comments