DEV Community

Discussion on: How to Force Re-Render a React Component & Should you do it?

Collapse
g100g profile image
Giorgio Aquino

I think the best way to force rendering is using key property on an component.

Change it and the component will update.

Collapse
ruppysuppy profile image
Tapajyoti Bose Author

Could you share an example snippet?

Collapse
g100g profile image
Giorgio Aquino

Check this good article from Kent C. Dodds, the last part with a Counter example show how to use a key to reset a component telling React to unmount and mount the component.

kentcdodds.com/blog/understanding-...

To use with great responsibility in mind :)