Building TUIs with React is nice
React for interactive command-line apps
https://github.com/vadimdemedes/ink
Another great example for that often overlooked React-Feature: fiber.
export default function App() {
const [input, setInput] = useState('');
const {entries, addEntry} = Worklog.useEntries();
const clearInput = useCallback(() => setInput(''), []);
return (
<FullScreenBox alignItems="stretch" flexDirection="column">
<Box flexGrow={1} flexDirection="column">
{entries.map((entry, index) => (
<Box width="100%">
<Text key={index}>
{Worklog.formatDate(new Date(entry.meta.createdAt))}: {entry.text}
</Text>
</Box>
))}
</Box>
<Box borderStyle="round" flexGrow={0} paddingX={1}>
<TextInput value={input} onChange={setInput} onSubmit={callAll(addEntry, clearInput)} />
</Box>
</FullScreenBox>
);
}