-
-
Notifications
You must be signed in to change notification settings - Fork 582
/
demo.js
55 lines (48 loc) · 1.05 KB
/
demo.js
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
46
47
48
49
50
51
52
53
54
55
import process from 'node:process';
import React from 'react';
import {render, Box, Text} from 'ink';
class Counter extends React.PureComponent {
constructor() {
super();
this.state = {
i: 0,
};
}
render() {
return React.createElement(
Box,
{flexDirection: 'column'},
React.createElement(
Box,
{},
React.createElement(Text, {color: 'blue'}, '~/Projects/ink '),
),
React.createElement(
Box,
{},
React.createElement(Text, {color: 'magenta'}, '❯ '),
React.createElement(Text, {color: 'green'}, 'node '),
React.createElement(Text, {}, 'media/example'),
),
React.createElement(
Text,
{color: 'green'},
`${this.state.i} tests passed`,
),
);
}
componentDidMount() {
this.timer = setInterval(() => {
if (this.state.i === 50) {
process.exit(0); // eslint-disable-line unicorn/no-process-exit
}
this.setState(previousState => ({
i: previousState.i + 1,
}));
}, 100);
}
componentWillUnmount() {
clearInterval(this.timer);
}
}
render(React.createElement(Counter));