'flex' property doesn't work with textRestyleFunctions
See original GitHub issueWe 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:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @msvargas
Text
not supportflex
and other layout properties seems to be a decision made by design by previous maintainers, aslayout
is not included intextRestyleFunctions
: https://github.com/Shopify/restyle/blob/master/src/createText.ts#L39I 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. 👍
😮 I didn’t know that I always split
Box
andText
to don’t overcomplicate things