Skip to content
Advertisement

Toggle Icon on Button click React

I am trying to toggle the button icon when clicked in React app. I looked into the console, the value of “togglePassword” is changing on click but the button icon is not changing… How to correct this out? Here is my code…

JavaScript

The other method I tried is as below but the console gave me the following error when I clicked the button…

JavaScript

Error: failed to execute “remove child” on “Node”. The node to be removed is not a child of this node.

Advertisement

Answer

There might be something else apart from the code you have provided,

Below code snippet, this is exact copy of your code, and its working fine :


JavaScript
JavaScript

WORKING DEMO : with font awesome

Edit #SO-react-font-awesome

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