Skip to content

Commit a577ef9

Browse files
committed
Update deps
1 parent 1ba1430 commit a577ef9

File tree

6 files changed

+66
-72
lines changed

6 files changed

+66
-72
lines changed

frameworks/keyed/rendrjs/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/keyed/rendrjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"webpack-cli": "5.1.4"
1111
},
1212
"dependencies": {
13-
"@rendrjs/core": "0.1.190"
13+
"@rendrjs/core": "0.1.194"
1414
},
1515
"js-framework-benchmark": {
1616
"frameworkVersionFromPackage": "@rendrjs/core",

frameworks/keyed/rendrjs/src/App.js

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ import { rendr, useCallback, useState } from '@rendrjs/core';
22
import Jumbotron from './Jumbotron';
33
import Row from './Row';
44

5-
const random = (max) => Math.round(Math.random() * 1000) % max;
5+
let random = (max) => Math.round(Math.random() * 1000) % max;
66

7-
const A = ['pretty', 'large', 'big', 'small', 'tall', 'short', 'long', 'handsome',
7+
let A = ['pretty', 'large', 'big', 'small', 'tall', 'short', 'long', 'handsome',
88
'plain', 'quaint', 'clean', 'elegant', 'easy', 'angry', 'crazy', 'helpful', 'mushy',
99
'odd', 'unsightly', 'adorable', 'important', 'inexpensive', 'cheap', 'expensive',
1010
'fancy'];
11-
const C = ['red', 'yellow', 'blue', 'green', 'pink', 'brown', 'purple', 'brown',
11+
let C = ['red', 'yellow', 'blue', 'green', 'pink', 'brown', 'purple', 'brown',
1212
'white', 'black', 'orange'];
13-
const N = ['table', 'chair', 'house', 'bbq', 'desk', 'car', 'pony', 'cookie',
13+
let N = ['table', 'chair', 'house', 'bbq', 'desk', 'car', 'pony', 'cookie',
1414
'sandwich', 'burger', 'pizza', 'mouse', 'keyboard'];
1515

1616
let nextId = 1;
1717

18-
const buildData = (count) => {
19-
const data = new Array(count);
18+
let buildData = (count) => {
19+
let data = new Array(count);
2020

2121
for (let i = 0; i < count; i++) {
2222
data[i] = {
@@ -28,58 +28,52 @@ const buildData = (count) => {
2828
return data;
2929
};
3030

31-
const preloadIcon = rendr('span', {
32-
className: 'preloadicon glyphicon glyphicon-remove',
31+
let preloadIcon = rendr('span', {
32+
class: 'preloadicon glyphicon glyphicon-remove',
3333
'aria-hidden': true,
3434
});
3535

36-
const App = () => {
37-
const [state, setState] = useState({ data: [], selected: 0 });
36+
let App = () => {
37+
let [state, setState] = useState({ arr: [], sel: 0 });
3838

39-
const onRun = useCallback(() => setState({ data: buildData(1000), selected: 0 }), []);
40-
const onRunlots = useCallback(() => setState({ data: buildData(10000), selected: 0 }), []);
41-
const onClear = useCallback(() => setState({ data: [], selected: 0 }), []);
42-
const onUpdate = useCallback(() => setState(old => {
43-
const newData = old.data.slice(0);
44-
for (let i = 0; i < newData.length; i += 10) {
45-
const r = newData[i];
46-
newData[i] = { id: r.id, label: r.label + ' !!!' };
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 => {
43+
for (let i = 0; i < old.arr.length; i += 10) {
44+
old.arr[i].label += ' !!!';
4745
}
48-
return { data: newData, selected: old.selected };
46+
return { ...old };
4947
}), []);
50-
const onSwap = useCallback(() => setState(old => {
51-
if (old.data.length > 998) {
52-
const d1 = old.data[1];
53-
const d998 = old.data[998];
54-
old.data[1] = d998;
55-
old.data[998] = d1;
56-
return { ...old };
48+
let swap = useCallback(() => setState(old => {
49+
if (old.arr.length > 998) {
50+
let one = old.arr[1];
51+
old.arr[1] = old.arr[998];
52+
old.arr[998] = one;
5753
}
58-
return { data: old.data, selected: 0 };
59-
}), []);
60-
const onAppend = useCallback(() => setState(old => {
61-
return { data: old.data.concat(buildData(1000)), selected: old.selected };
54+
return { ...old, sel: 0 };
6255
}), []);
63-
const onDelete = useCallback((id) => setState(old => {
64-
old.data.splice(old.data.findIndex((d) => d.id === id), 1);
56+
let push = useCallback(() => setState(old => ({ arr: old.arr.concat(buildData(1000)), sel: old.sel })), []);
57+
let del = useCallback((id) => setState(old => {
58+
old.arr.splice(old.arr.findIndex((d) => d.id === id), 1);
6559
return { ...old };
6660
}), []);
67-
const onSelect = useCallback((id) => setState(old => ({ ...old, selected: id })), []);
61+
let select = useCallback((id) => setState(old => ({ ...old, sel: id })), []);
6862

6963
return rendr('div', {
70-
className: 'container',
64+
class: 'container',
7165
slot: [
72-
rendr(Jumbotron, { onRun, onRunlots, onClear, onUpdate, onSwap, onAppend, memo: [] }),
66+
rendr(Jumbotron, { run, lots, clear, update, swap, push, memo: [] }),
7367
rendr('table', {
74-
className: 'table table-hover table-striped test-data',
68+
class: 'table table-hover table-striped test-data',
7569
slot: rendr('tbody', {
76-
slot: state.data.map(item => rendr(Row, {
70+
slot: state.arr.map(item => rendr(Row, {
7771
key: `${item.id}`,
78-
item: item,
79-
selected: state.selected === item.id,
80-
onSelect,
81-
onDelete,
82-
memo: [item.id === state.selected, item.label],
72+
item,
73+
sel: state.sel === item.id,
74+
select,
75+
del,
76+
memo: [item.id === state.sel, item.label],
8377
})),
8478
}),
8579
}),

frameworks/keyed/rendrjs/src/Button.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { rendr } from '@rendrjs/core';
22

3-
const Button = (props) => {
3+
let Button = (props) => {
44
return rendr('div', {
5-
className: 'col-sm-6 smallpad',
5+
class: 'col-sm-6 smallpad',
66
slot: rendr('button', {
77
id: props.id,
88
onclick: props.cb,
99
type: 'button',
10-
className: 'btn btn-primary btn-block',
11-
slot: props.title,
10+
class: 'btn btn-primary btn-block',
11+
slot: props.text,
1212
}),
1313
});
1414
};

frameworks/keyed/rendrjs/src/Jumbotron.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
import { rendr } from '@rendrjs/core';
22
import Button from './Button';
33

4-
const Jumbotron = (props) => {
4+
let Jumbotron = (props) => {
55
return rendr('div', {
6-
className: 'jumbotron',
6+
class: 'jumbotron',
77
slot: rendr('div', {
8-
className: 'row',
8+
class: 'row',
99
slot: [
1010
rendr('div', {
11-
className: 'col-md-6',
11+
class: 'col-md-6',
1212
slot: rendr('h1', { slot: 'Rendrjs keyed' }),
1313
}),
1414
rendr('div', {
15-
className: 'col-md-6',
15+
class: 'col-md-6',
1616
slot: rendr('div', {
17-
className: 'row',
17+
class: 'row',
1818
slot: [
19-
rendr(Button, { id: 'run', title: 'Create 1,000 rows', cb: props.onRun }),
20-
rendr(Button, { id: 'runlots', title: 'Create 10,000 rows', cb: props.onRunlots }),
21-
rendr(Button, { id: 'add', title: 'Append 1,000 rows', cb: props.onAppend }),
22-
rendr(Button, { id: 'update', title: 'Update every 10th row', cb: props.onUpdate }),
23-
rendr(Button, { id: 'clear', title: 'Clear', cb: props.onClear }),
24-
rendr(Button, { id: 'swaprows', title: 'Swap rows', cb: props.onSwap }),
19+
rendr(Button, { id: 'run', text: 'Create 1,000 rows', cb: props.run }),
20+
rendr(Button, { id: 'runlots', text: 'Create 10,000 rows', cb: props.lots }),
21+
rendr(Button, { id: 'add', text: 'Append 1,000 rows', cb: props.push }),
22+
rendr(Button, { id: 'update', text: 'Update every 10th row', cb: props.update }),
23+
rendr(Button, { id: 'clear', text: 'Clear', cb: props.clear }),
24+
rendr(Button, { id: 'swaprows', text: 'Swap rows', cb: props.swap }),
2525
],
2626
}),
2727
}),

frameworks/keyed/rendrjs/src/Row.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
import { rendr } from '@rendrjs/core';
22

3-
const Row = (props) => {
3+
let Row = props => {
44
return rendr('tr', {
5-
className: props.selected ? 'danger' : undefined,
5+
class: props.sel ? 'danger' : undefined,
66
slot: [
77
rendr('td', {
8-
className: 'col-md-1',
8+
class: 'col-md-1',
99
slot: `${props.item.id}`,
1010
}),
1111
rendr('td', {
12-
className: 'col-md-4',
12+
class: 'col-md-4',
1313
slot: rendr('a', {
14-
onclick: () => props.onSelect(props.item.id),
14+
onclick: () => props.select(props.item.id),
1515
slot: props.item.label,
1616
}),
1717
}),
1818
rendr('td', {
19-
className: 'col-md-1',
19+
class: 'col-md-1',
2020
slot: rendr('a', {
21-
onclick: () => props.onDelete(props.item.id),
21+
onclick: () => props.del(props.item.id),
2222
slot: rendr('span', {
23-
className: 'glyphicon glyphicon-remove',
23+
class: 'glyphicon glyphicon-remove',
2424
'aria-hidden': true,
2525
}),
2626
}),
2727
}),
2828
rendr('td', {
29-
className: 'col-md-6',
29+
class: 'col-md-6',
3030
}),
3131
],
3232
});

0 commit comments

Comments
 (0)