Skip to content

Commit

Permalink
Clarify <Transform> usage in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Demedes committed Jun 20, 2020
1 parent 293d40f commit 7885ffd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -987,10 +987,16 @@ For example, you might want to apply a [gradient to text](https://github.com/sin
These use cases can't accept React nodes as input, they are expecting a string.
That's what `<Transform>` component does, it gives you an output string of its child components and lets you transform it in any way.

**Note:** `<Transform>` must be applied only to `<Text>` children components and shouldn't change the dimensions of the output, otherwise layout will be incorrect.

```jsx
<Transform transform={output => output.toUpperCase()}>
<Text>Hello World</Text>
</Transform>
import {Transform} from 'ink';

const Example = () => (
<Transform transform={output => output.toUpperCase()}>
<Text>Hello World</Text>
</Transform>
);
```

Since `transform` function converts all characters to upper case, final output that's rendered to the terminal will be "HELLO WORLD", not "Hello World".
Expand Down

0 comments on commit 7885ffd

Please sign in to comment.