我收到一个错误,属性'ref‘在类型'IntrinsicAttributes & PhoneInputProps &{ReactNode?:ReactNode;}’上不存在。我该如何解决这个问题?
import React, {ForwardedRef} from 'react';
import PhoneInput from 'react-phone-input-2';
import 'react-phone-input-2/lib/bootstrap.css'
const FormikPhoneInput = React.forwardRef(
({ name, country, ...rest }: {name: string, country: string}, ref: React.ForwardedRef<any>) => (
<PhoneInput {...rest} ref={ref} name={name} />
)
);
export default FormikPhoneInput;发布于 2021-06-02 18:38:11
看起来您需要将inputProps作为对象进行传递。
<PhoneInput {...rest} inputProps={{ ref }} name={name} />https://stackoverflow.com/questions/67803466
复制相似问题