|
1 |
| -import { rendr, useCallback, useState } from '@rendrjs/core'; |
| 1 | +import { rendr, useState } from '@rendrjs/core'; |
2 | 2 | import Jumbotron from './Jumbotron';
|
3 | 3 | import Row from './Row';
|
4 | 4 |
|
@@ -36,29 +36,29 @@ let preloadIcon = rendr('span', {
|
36 | 36 | let App = () => {
|
37 | 37 | let [state, setState] = useState({ arr: [], sel: 0 });
|
38 | 38 |
|
39 |
| - let run = useCallback(() => setState({ arr: buildData(1000), sel: 0 }), []); |
40 |
| - let lots = useCallback(() => setState({ arr: buildData(10000), sel: 0 }), []); |
41 |
| - let clear = useCallback(() => setState({ arr: [], sel: 0 }), []); |
42 |
| - let update = useCallback(() => setState(old => { |
| 39 | + let run = () => setState({ arr: buildData(1000), sel: 0 }); |
| 40 | + let lots = () => setState({ arr: buildData(10000), sel: 0 }); |
| 41 | + let clear = () => setState({ arr: [], sel: 0 }); |
| 42 | + let update = () => setState(old => { |
43 | 43 | for (let i = 0; i < old.arr.length; i += 10) {
|
44 | 44 | old.arr[i].label += ' !!!';
|
45 | 45 | }
|
46 | 46 | return { ...old };
|
47 |
| - }), []); |
48 |
| - let swap = useCallback(() => setState(old => { |
| 47 | + }); |
| 48 | + let swap = () => setState(old => { |
49 | 49 | if (old.arr.length > 998) {
|
50 | 50 | let one = old.arr[1];
|
51 | 51 | old.arr[1] = old.arr[998];
|
52 | 52 | old.arr[998] = one;
|
53 | 53 | }
|
54 | 54 | return { ...old, sel: 0 };
|
55 |
| - }), []); |
56 |
| - let push = useCallback(() => setState(old => ({ arr: old.arr.concat(buildData(1000)), sel: old.sel })), []); |
57 |
| - let del = useCallback((id) => setState(old => { |
| 55 | + }); |
| 56 | + let push = () => setState(old => ({ arr: old.arr.concat(buildData(1000)), sel: old.sel })); |
| 57 | + let del = (id) => setState(old => { |
58 | 58 | old.arr.splice(old.arr.findIndex((d) => d.id === id), 1);
|
59 | 59 | return { ...old };
|
60 |
| - }), []); |
61 |
| - let select = useCallback((id) => setState(old => ({ ...old, sel: id })), []); |
| 60 | + }); |
| 61 | + let select = id => setState(old => ({ ...old, sel: id })); |
62 | 62 |
|
63 | 63 | return rendr('div', {
|
64 | 64 | class: 'container',
|
|
0 commit comments