Open hwhh opened 11 months ago
Warning when using React.forwardRef to hand in ref to textField.
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Check the render method of Incubator.TextField.
Incubator.TextField
export const A = () => { const aRef = useRef<TextFieldRef>(null); return ( <View > <B onChangeText={setPhoneNumber} ref={numberRef} /> <Button onPress={() => { console.log(numberRef?.current?.validate()); }} /> </View> ); } export const B = forwardRef((props: TextFieldProps, ref: ForwardedRef<TextFieldRef>) => { return ( <TextField ref={ref} {...props} /> ); }
It's happening to me as well. Any ideas?
Description
Warning when using React.forwardRef to hand in ref to textField.
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Check the render method of
Incubator.TextField
.Related to
Code snippet
Screenshots/Video
Environment
Affected platforms