Skip to content
Advertisement

why the createRef current always null in react

I am developing a simple edit app page, because the form.item initial value did not update by data, so I want to setFieldsValue in the antd 4.x, this is my code looks like:

JavaScript

To my surprise, the formRef.current is always null. Am I missing something? what should I do to make the Form.Item value update by data which passed from other component?

Advertisement

Answer

CreateRef work only with class components , you can use the hooks useRef if your react versions support it

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement