-
-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix rendering when terminal is erased on first render
- Loading branch information
1 parent
1e94572
commit c2cc085
Showing
5 changed files
with
121 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import process from 'node:process'; | ||
import React, {useState} from 'react'; | ||
import {Box, Static, Text, render, useInput} from '../../src/index.js'; | ||
|
||
function Test() { | ||
const [fullHeight, setFullHeight] = useState(true); | ||
|
||
useInput( | ||
input => { | ||
if (input === 'x') { | ||
setFullHeight(false); | ||
} | ||
}, | ||
{isActive: fullHeight} | ||
); | ||
|
||
return ( | ||
<> | ||
<Static items={['X', 'Y', 'Z']}> | ||
{item => <Text key={item}>{item}</Text>} | ||
</Static> | ||
|
||
<Box flexDirection="column"> | ||
<Text>A</Text> | ||
<Text>B</Text> | ||
{fullHeight && <Text>C</Text>} | ||
</Box> | ||
</> | ||
); | ||
} | ||
|
||
process.stdout.rows = Number(process.argv[2]); | ||
render(<Test />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import process from 'node:process'; | ||
import React, {useState} from 'react'; | ||
import {Box, Text, render, useInput} from '../../src/index.js'; | ||
|
||
function Test() { | ||
const [fullHeight, setFullHeight] = useState(true); | ||
|
||
useInput( | ||
input => { | ||
if (input === 'x') { | ||
setFullHeight(false); | ||
} | ||
}, | ||
{isActive: fullHeight} | ||
); | ||
|
||
return ( | ||
<Box flexDirection="column"> | ||
<Text>A</Text> | ||
<Text>B</Text> | ||
{fullHeight && <Text>C</Text>} | ||
</Box> | ||
); | ||
} | ||
|
||
process.stdout.rows = Number(process.argv[2]); | ||
render(<Test />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters