Bot releases are visible (Hide)
This day is finally here - Ink 3 is out! Read the full announcement at https://vadimdemedes.com/posts/ink-3.
measureElement()
API (#307) d0c4417<Box>
component (#300) 96625bfalign-self
property to <Box>
(#296) 125148a<Spacer>
component e8ae2af<Newline>
component 9f4c6f8console.*
logs above main output acb6ed2clear()
method to clear output fec1c4duseStderr
hook to access and write to stderr stream (#286) 360d2dawrite()
function to write any string to stdout (#285) 27e313e<Transform>
component (#277) 9ed46a5false
a056565isActive
option to useInput hook f419028<Box display="none">
b51476c<Box>
to include ref
prop (#330) 32d331ehttps://github.com/vadimdemedes/ink/compare/v3.0.0-6...v3.0.0-7
https://github.com/vadimdemedes/ink/compare/v3.0.0-5...v3.0.0-6
https://github.com/vadimdemedes/ink/compare/v3.0.0-4...v3.0.0-5
<Text>
and <Transform>
components with falsy children (#315) 8e68295https://github.com/vadimdemedes/ink/compare/v3.0.0-3...v3.0.0-4
useInput
hook (#314) 0692fa5https://github.com/vadimdemedes/ink/compare/v3.0.0-2...v3.0.0-3
useInput
hook (#312) a715395https://github.com/vadimdemedes/ink/compare/v3.0.0-1...v3.0.0-2
cleanup()
method (internal method) c358a06https://github.com/vadimdemedes/ink/compare/v3.0.0-0...v3.0.0-1
Ink 3 pre-release is finally here. I'm going to save detailed release description for 3.0.0, but in this one I'm going to link to all important changes that were made and highlight the breaking ones.
$ npm install ink@next react
<Text>
component (#299)There are much more details on this change in the linked PR above, but the TLDR is that all text must be wrapped in <Text>
component now. Otherwise Ink will throw an error like this:
Text string "Hello World" must be rendered inside component
If you've used to building apps with React Native, Ink now has the same requirement in regards to text so it should feel familiar to you.
// Before
<Box>Hello World</Box>
// After
<Text>Hello World</Text>
Note: It's allowed to have nested <Text>
components.
<Color>
component functionality into <Text>
(#301)In Ink 3 there's no more <Color>
component. Instead, you can use color
and backgroundColor
props directly in <Text>
. The way you specify colors has also changed a bit. Before there was a separate prop for each color, now there are just two props, which accept CSS-like values.
// Before
<Color red>
<Text>Hello World</Text>
</Color>
<Color hex="#ffffff">
<Text>Hello World</Text>
</Color>
<Color white bgGreen>
<Text>Hello World</Text>
</Color>
// After
<Text color="red">Hello World</Text>
<Text color="#ffffff">Hello World</Text>
<Text color="white" backgroundColor="green">Hello World</Text>
<div>
and <span>
(#306)It was "illegal" to use these tags directly before, but now they're removed completely. If you are using them, switch from <div>
to <Box>
and from <span>
to <Text>
.
unstable__transformChildren
from <Box>
and <Text>
(ab36e7f)Previously this function was used to transform the string representation of component's children
. You can still do the same stuff, but you should use <Transform>
component instead.
// Before
<Box unstable__transformChildren={children => children.toUpperCase()}>
Hello World
</Box>
// After
<Transform transform={children => children.toUpperCase()}>
<Text>Hello World</Text>
</Transform>
AppContext
, StdinContext
and StdoutContext
in favor of useApp
, useStdin
and useStdout
hooks 055a196Hooks are the future.
// Before
import {AppContext, StdinContext, StdoutContext} from 'ink';
const Example = () => (
<AppContext.Consumer>
{appProps => (
<StdinContext.Consumer>
{stdinProps => (
<StdoutContext.Consumer>
{stdoutProps => (
…
)}
</StdoutContext.Consumer>
)}
</StdinContext.Consumer>
)}
</AppContext.Consumer>
);
// After
import {useApp, useStdin, useStdout} from 'ink';
const Example = () => {
const appProps = useApp();
const stdinProps = useStdin();
const stdoutProps = useStdout();
return …;
};
<Static>
component (#281)Functionality has remained the same, but API has changed and performance has significantly improved. New API looks very similar to the one commonly used in virtual list libraries, like react-tiny-virtual-list
.
// Before
<Static>
{items.map(item => (
<Text key={item.id}>
{item.title}
</Text>
))}
</Static>
// After
<Static items={items}>
{item => (
<Text key={item.id}>
{item.title}
</Text>
)}
</Static>
measureElement()
API (#307) d0c4417<Box>
component (#300) 96625bfalign-self
property to <Box>
(#296) 125148a<Spacer>
component e8ae2af<Newline>
component 9f4c6f8console.*
logs above main output acb6ed2clear()
method to clear output fec1c4duseStderr
hook to access and write to stderr stream (#286) 360d2dawrite()
function to write any string to stdout (#285) 27e313e<Transform>
component (#277) 9ed46a5false
a056565isActive
option to useInput hook f419028<Box display="none">
b51476chttps://github.com/vadimdemedes/ink/compare/v2.7.1...v3.0.0-0
@types/react
to be an optional peer dependency (#257) 084cded@types/react
from dependencies (#236) 58314dfuseApp
, useStdin
and useStdout
hooks (#235) e0d2b4f<Box>
1f96300useInput
hook to handle user input (#227) 4960ff7react
, react-reconciler
and scheduler
dependencies, which fixes useEffect
hook usage 4a0afb6 9487c00<Static>
component 78be775setRawMode()
with non-TTY stdin and expose isRawModeSupported
on StdinContext
https://github.com/vadimdemedes/ink/commit/7f0b2c086972788702dd283b30e379a8c061638d
❤️ Thanks to @eweilow for contributing towards this release!
waitUntilExit()
promise if error occurs during render (#178) 526d5c3❤️ Thanks to @mAAdhaTTah, @sindresorhus and @sebald for contributing to this release!