forked from vadimdemedes/ink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuse-stdout.js
More file actions
38 lines (32 loc) · 695 Bytes
/
use-stdout.js
File metadata and controls
38 lines (32 loc) · 695 Bytes
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
'use strict';
const React = require('react');
const {render, Box, Text, useStdout} = require('../..');
const Example = () => {
const {stdout, write} = useStdout();
React.useEffect(() => {
const timer = setInterval(() => {
write('Hello from Ink to stdout\n');
}, 1000);
return () => {
clearInterval(timer);
};
}, []);
return (
<Box flexDirection="column" paddingX={2} paddingY={1}>
<Text bold underline>
Terminal dimensions:
</Text>
<Box marginTop={1}>
<Text>
Width: <Text bold>{stdout.columns}</Text>
</Text>
</Box>
<Box>
<Text>
Height: <Text bold>{stdout.rows}</Text>
</Text>
</Box>
</Box>
);
};
render(<Example />);