You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not forcing you to pass the custom component props as generic, this leads to add all the RN Text props to the restyled custom component.
constCustomText=({ title }: {title: string})=><Text>{title}</Text>;constRestyledCustomText=createText<Theme>(CustomText);<RestyledCustomTextcolor="lightpink"accessibilityLabel="I am a label"/>;
There is no type inference between the generic and the props of the passed component:
constCustomText=({ title }: {title: string})=><Text>{title}</Text>;constRestyledCustomText=createText<Theme,{}>(CustomText);
We are not forcing the passed custom text to have a style prop (the style prop will contain all the calculated props as a style object)
I believe the same applied for createBox.
The text was updated successfully, but these errors were encountered:
I haven't checked your PR yet, but createText is aimed to be a shorthand of creating a restyle component based on react-native's Text, hence, they are coupled by design.
If you would like to create a restyle version of a custom component you should use createRestyleComponent instead. i.e.:
import {TextProps as RNTextProps} from 'react-native'
import {
createRestyleComponent,
textRestyleFunctions,
TextProps as RestyleTextProps,
} from '@shopify/restyle'
import {Theme} from './theme'
import {CustomText} from './CustomText'
type CustomTextProps = RestyleTextProps<Theme> &
Omit<
RNTextProps,
| 'fontWeight'
| 'fontFamily'
| 'fontSize'
| 'lineHeight'
| 'letterSpacing'
| 'style'
>
const CustomRestyleText = createRestyleComponent<CustomTextProps, Theme>(
textRestyleFunctions,
CustomText
)
export const Text = (props: CustomTextProps) => {
return (
<CustomRestyleText
{...props}
/>
)
}
But then why we can pass an optional BaseComponent to createText + the props as generic?
Cause for me, looking at that, I thought that createText and createView can also be used as a customised createRestyleComponent for Text and View.
What:
I believe the same applied for
createBox
.The text was updated successfully, but these errors were encountered: