-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'flex' property doesn't work with textRestyleFunctions #132
Comments
Hey @msvargas On the React Native documentation |
Hey @flexbox thank you for your answer but yes it supports all view styles, look at this: https://reactnative.dev/docs/text#style Also, other properties like position, top, left,bottom, right, flexShrink, ...etc doesn't work either |
😮 I didn't know that I always split |
Hey @msvargas
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 Finally, If you do want layout props in your Text I think it's perfectly fine to add them manually as you did. 👍 |
Hi @sbalay thanks, I needed flexShrink to shrink the text well in some cases (for example with allowFontScaling equals to true) but also I agree with you about separating responsibilities |
import {Theme} from '@/theme';
import {createText} from '@shopify/restyle';
import {ComponentProps} from 'react';
import {TextStyle} from 'react-native';
const BaseText = createText<Theme>();
type Props = ComponentProps<typeof BaseText> &
Pick<TextStyle, 'flex' | 'flexShrink' | 'flexGrow'>;
export default function Text(props: Props) {
const {style, flex, flexGrow, flexShrink, ...rest} = props;
return (
<BaseText
style={[
{
flex,
flexGrow,
flexShrink,
},
style,
]}
{...rest}
/>
);
} |
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)
The text was updated successfully, but these errors were encountered: