-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.mjs
45 lines (35 loc) · 1.23 KB
/
test.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { createElement, useEffect, useState } from "@my-react/react";
import { Text, render, Box } from "@my-react/react-terminal";
const App = () => {
const [a, setA] = useState(0);
if (a < 10) {
setA(a + 1);
}
useEffect(() => {
const i = setInterval(() => {
setA((i) => i + 1);
}, 1000);
return () => {
// console.log('unmount');
clearInterval(i);
};
}, []);
// console.log(a);
return createElement(
Box,
{ borderStyle: "round", borderColor: a % 2 === 0 ? "green" : "red" },
createElement(Text, { backgroundColor: a % 2 === 0 ? "yellow" : "blue", strikethrough: true, underline: true, italic: true }, a),
a % 2 === 0
? createElement(Box, { borderStyle: "round", borderColor: "green" }, createElement(Text, { bold: true }, "test"))
: createElement(Text, { backgroundColor: "red" }, "test", 12)
// :createElement(Box, { borderStyle: "round", borderColor: "red" }, createElement(Text, {}, "test red"))
// a
);
};
const run = () => {
const test = "hello world";
// render(createElement(Text, {}, test));
// render(createElement(Box, { borderStyle: "round", borderColor: "green" }, createElement(Text, {}, test)));
render(createElement(App));
};
run();