|
1 | | -import { h, render, useState } from "../../src/index" |
| 1 | +import { h, render, useState, Fragment } from "../../src/index" |
2 | 2 | // import {h, render} from '../../.ignore/eee' |
3 | 3 |
|
| 4 | +const states = [ |
| 5 | + [3, 1, 2], // shift right |
| 6 | + [1, 2, 3], |
| 7 | + [2, 3, 1], // shift left |
| 8 | + [1, 2, 3], |
| 9 | + [1, 3], // remove from middle |
| 10 | + [1, 2, 3], |
| 11 | + [2, 3], // remove first |
| 12 | + [1, 2, 3], |
| 13 | + [1, 2], // remove last |
| 14 | + [1, 2, 3], |
| 15 | + [3, 2, 1], // reverse order |
| 16 | +] |
| 17 | + |
| 18 | +function App() { |
| 19 | + const [state, setState] = useState(true) |
| 20 | + return <> |
| 21 | + <button onClick={() => setState(!state)}>change</button> |
| 22 | + {state ? <h1>0</h1> : <a>none</a>} |
| 23 | + </> |
| 24 | +} |
| 25 | + |
4 | 26 | // function App() { |
5 | | -// const [key, setKey] = useState([3,1,2]) |
| 27 | +// const [key, setKey] = useState([1,2,3]) |
| 28 | +// const [count, setCount] = useState(0) |
6 | 29 | // return [ |
7 | | -// <button onClick={() => setKey([1,2,3])}>x</button>, |
| 30 | +// <button onClick={() => { |
| 31 | +// setKey(states[count]) |
| 32 | +// setCount(count + 1) |
| 33 | +// }}>x</button>, |
8 | 34 | // <ul> |
9 | 35 | // {key.map((i) => ( |
10 | 36 | // <li key={i}>{i}</li> |
@@ -48,17 +74,17 @@ import { h, render, useState } from "../../src/index" |
48 | 74 | // return <div>{list.map((d) => <span>{d}</span>)} <button onClick={() => setList(list.concat(4))}>+</button></div> |
49 | 75 | // } |
50 | 76 |
|
51 | | -const App = () => { |
52 | | - let [bool, setbool] = useState(true) |
53 | | - return <div> |
54 | | - {bool ? <Header /> : null} |
55 | | - <button onClick={()=>setbool(!bool)}>x</button> |
56 | | - </div> |
57 | | -} |
| 77 | +// const App = () => { |
| 78 | +// let [bool, setbool] = useState(true) |
| 79 | +// return <div> |
| 80 | +// {bool ? <Header /> : null} |
| 81 | +// <button onClick={()=>setbool(!bool)}>x</button> |
| 82 | +// </div> |
| 83 | +// } |
58 | 84 |
|
59 | | -function Header(){ |
60 | | - return <div><a href="">222</a></div> |
61 | | -} |
| 85 | +// function Header(){ |
| 86 | +// return <div><a href="">222</a></div> |
| 87 | +// } |
62 | 88 |
|
63 | 89 | // function App() { |
64 | 90 | // const [key, setKey] = useState([1,2,3,4,5]) |
|
0 commit comments