question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'flex' property doesn't work with textRestyleFunctions

See original GitHub issue

We found some inconsistency with textRestyleFunctions add flex property and it doesn’t work I had to add layout restylefunction and it works

Example: (doesn’t work for me v1.6.1)

<Text flex={1}>Test</Text>
import { layout, TextProps as RestyleTextProps, textRestyleFunctions } from '@shopify/restyle';

.....
const restyleFunctions = [...textRestyleFunctions, layout];
....
const props = useRestyle(restyleFunctions, rest);

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
sbalaycommented, Mar 27, 2022

Hey @msvargas

Text not support flex and other layout properties seems to be a decision made by design by previous maintainers, as layout is not included in textRestyleFunctions: https://github.com/Shopify/restyle/blob/master/src/createText.ts#L39

I guess the motivation was similar to what @flexbox mentioned above, and have a clear separation of resposibilities between Box and Text, but can’t say for sure as I wasn’t around back then.

If using typescript, you should get a type error when trying to apply flex to your Text component (before adding layout props to it.

Finally, If you do want layout props in your Text I think it’s perfectly fine to add them manually as you did. 👍

1reaction
flexboxcommented, Mar 11, 2022

😮 I didn’t know that I always split Box and Text to don’t overcomplicate things

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flex property doesn't work on flexboxes set to column, but ...
I have a container flex box that contains 3 more divs. I want them to be displayed below each other and set a...
Read more >
flex - CSS: Cascading Style Sheets - MDN Web Docs
The flex CSS shorthand property sets how a flex item will grow or shrink to fit the space available in its flex container....
Read more >
Flex-grow doesn't work - CSS-Tricks
Hi! In my code the flex-grow doesn't work. I use it at first time, my code more complex than in the flex-box tutorials...
Read more >
The min-width and max-width declaration for Flexbox doesn't ...
The min-width and max-width declaration for Flexbox doesn't work on Safari? Why? ... We have use the CSS Flex shorthand property −.
Read more >
CSS Flex positioning gotchas: child expands to more than the ...
Also, text-overflow does not work on display: flex elements, ... child2 and set the text-overflow , whitespace and overflow properties on this container, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found