How to clear input values of dynamic form in React?

Posted by Andre Scott | Updated on

Want to clear input values of dynamic form in React? The problem is that the inputs are not controlled by state as you have deduced. We should create an updated object for each item from your API, giving it a value prop.

index.js

Cart.js

The Cart component can remain mostly the same, we do not need to pass in props.items to useEffect() dependency.

Form.js


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers