Skip to content

Commit d9adeea

Browse files
committed
emmm
1 parent db3c52b commit d9adeea

4 files changed

Lines changed: 1062 additions & 1061 deletions

File tree

‎tui/README.md‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# fre/tui
2+
3+
#### Hello world
4+
5+
```jsx
6+
import ReactCurse, { Text } from 'fre/tui'
7+
8+
const App = ({ text }) => {
9+
return <Text color="Red">{text}</Text>
10+
}
11+
12+
FreTUI.render(<App text="hello world" />)
13+
```
14+
15+
#### How to handle input
16+
17+
```jsx
18+
import { useState } from 'react'
19+
import ReactCurse, { Text, useInput, exit } from 'fre/tui'
20+
21+
const App = () => {
22+
const [counter, setCounter] = useState(0)
23+
24+
useInput(
25+
input => {
26+
if (input === 'k') setCounter(counter + 1)
27+
if (input === 'j') setCounter(counter - 1)
28+
if (input === 'q') exit()
29+
},
30+
[counter]
31+
)
32+
33+
return (
34+
<Text>
35+
counter: <Text bold>{counter}</Text>
36+
</Text>
37+
)
38+
}
39+
40+
FreTUI.render(<App />)
41+
```

0 commit comments

Comments
 (0)