Ink v3.0.0-1 Release Notes

Release Date: 2020-06-21 // 17 days ago

Previous changes from v3.0.0-0

  • 🚀 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

    💥 Breaking changes

    Text must be wrapped in <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.

    🔀 Merged <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\>

    ✂ Removed <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>.

    ✂ Removed 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\>

    ✂ Removed AppContext, StdinContext and StdoutContext in favor of useApp, useStdin and useStdout hooks 055a196

    Hooks are the future.

    // Beforeimport {AppContext, StdinContext, StdoutContext} from 'ink';const Example = () =\> ( \<AppContext.Consumer\> {appProps =\> ( \<StdinContext.Consumer\> {stdinProps =\> ( \<StdoutContext.Consumer\> {stdoutProps =\> ( … )} \</StdoutContext.Consumer\> )} \</StdinContext.Consumer\> )} \</AppContext.Consumer\> );// Afterimport {useApp, useStdin, useStdout} from 'ink';const Example = () =\> { const appProps = useApp(); const stdinProps = useStdin(); const stdoutProps = useStdout(); return …; };

    🆕 New <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\> { =\> ( \<Text key={}\> {item.title} \</Text\> ))}\</Static\>// After\<Static items={items}\> {item =\> ( \<Text key={}\> {item.title} \</Text\> )}\</Static\>