Ad

Uncontrolled Textbox, Update DefaultValue

- 1 answer

I have an uncontrolled textbox. I set the defaultValue on it. When I change the defaultValue shouldn't it update/re-render the textbox? It is not doing so, does anyone know how I can make this work?

Thanks

Ad

Answer

From React docs:

Note:

The defaultValue and defaultChecked props are only used during initial render. If you need to update the value in a subsequent render, you will need to use a controlled component.

Ad
source: stackoverflow.com
Ad