fix unnamed component lint error

This commit is contained in:
Ansh Nanda
2023-09-13 09:59:59 +05:30
parent 3ec6701b8e
commit c827c226ef
+15 -10
View File
@@ -77,19 +77,20 @@ export function useStyles<T = ComponentProps>(props: Props<T> & T) {
return {styles, props: rest} return {styles, props: rest}
} }
export const Box = React.forwardRef<View, Props<ViewProps>>( export const Box = React.forwardRef<View, Props<ViewProps>>(function BoxThemed(
({children, style, ...props}, ref) => { {children, style, ...props},
ref,
) {
const {styles, props: rest} = useStyles<ViewProps>(props) const {styles, props: rest} = useStyles<ViewProps>(props)
return ( return (
<View {...rest} style={[styles, style]} ref={ref}> <View {...rest} style={[styles, style]} ref={ref}>
{children} {children}
</View> </View>
) )
}, })
)
export const Text = React.forwardRef<RNText, Props<TextProps>>( export const Text = React.forwardRef<RNText, Props<TextProps>>(
({children, style, ...props}, ref) => { function TextThemed({children, style, ...props}, ref) {
const {styles, props: rest} = useStyles<TextProps>({ const {styles, props: rest} = useStyles<TextProps>({
color: 'text', color: 'text',
...props, ...props,
@@ -144,7 +145,10 @@ const asToTypeStyles: {
}, },
} }
export const P = React.forwardRef<RNText, TypeProps>((props, ref) => { export const P = React.forwardRef<RNText, TypeProps>(function PThemed(
props,
ref,
) {
// @ts-expect-error role is web only // @ts-expect-error role is web only
return <Text role="paragraph" c="text" {...props} ref={ref} /> return <Text role="paragraph" c="text" {...props} ref={ref} />
}) })
@@ -154,8 +158,10 @@ export const P = React.forwardRef<RNText, TypeProps>((props, ref) => {
* @see https://docs.expo.dev/develop/user-interface/fonts/ * @see https://docs.expo.dev/develop/user-interface/fonts/
*/ */
function createHeadingComponent(element: HeadingElements) { function createHeadingComponent(element: HeadingElements) {
return React.forwardRef<RNText, TypeProps>( return React.forwardRef<RNText, TypeProps>(function HeadingThemed(
({children, style, as, ...props}, ref) => { {children, style, as, ...props},
ref,
) {
const asEl = as || element const asEl = as || element
const extra = Platform.select({ const extra = Platform.select({
web: { web: {
@@ -178,8 +184,7 @@ function createHeadingComponent(element: HeadingElements) {
{children} {children}
</RNText> </RNText>
) )
}, })
)
} }
export const H1 = createHeadingComponent('h1') export const H1 = createHeadingComponent('h1')