小编suv*_*dal的帖子

类型错误:组件不是添加forwardRef的函数

您好,我试图将forwardRef添加到子组件,但在添加forwardRef时得到以下信息: TypeError: Component is not a function

该组件定义如下:

import React from 'react';
import { forwardRef } from 'react';
import { TextInputFocusEventData } from 'react-native';
import { NativeSyntheticEvent, StyleSheet } from 'react-native';
import { Input, InputProps } from 'react-native-elements';
import { Metrics, Colors } from '../../theme';
import Icons from '../Icons';


const CustomTextInput2 = forwardRef<TextInput, ICustomtextnputProps>((props, ref) => {
    const { name, required } = props;

    return (
        <Input
            rightIcon={<Icons name="right" />}
            placeholder={name?.concat(required ? '*' : '')}
            inputContainerStyle={styles.inputContainer}
            inputStyle={styles.inputText}
            {...props}
        />
    ) …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-hooks react-forwardref

29
推荐指数
1
解决办法
1万
查看次数