Skip to content

Commit 9988165

Browse files
committedApr 12, 2019
add button to configure childFirst
1 parent 5f317c5 commit 9988165

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
 

‎demo/stateOrderBug.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ const html = htm.bind(h);
66

77
// configuration used to show behavior vs. workaround
88
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>`;
918

1019
const Child = ({ items,setItems }) => {
1120
let [pendingId, setPendingId] = useState(null);
@@ -46,7 +55,7 @@ const Child = ({ items,setItems }) => {
4655

4756
const Parent = () => {
4857
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>`;
5059
};
5160

5261
export default Parent;

0 commit comments

Comments
 (0)
Please sign in to comment.