From 4bfd7e9ccc6b689bc70f97feb215f5a824c98f77 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Thu, 18 Oct 2018 20:04:22 +0300 Subject: [PATCH] Add PasswordRevealer --- snippets/PasswordRevealer.md | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 snippets/PasswordRevealer.md diff --git a/snippets/PasswordRevealer.md b/snippets/PasswordRevealer.md new file mode 100644 index 000000000..79d2b321f --- /dev/null +++ b/snippets/PasswordRevealer.md @@ -0,0 +1,45 @@ +### PasswordRevealer + +Renders a password input field with a reveal button. + +Initially set `state.shown` to `false` to ensure that the password is not shown by default. +Create a method, `toggleShown`, which uses `Component.prototype.setState` to change the input's state from shown to hidden and vice versa, bind it to the component's context. +In the`render()` method, use a`
` to wrap both the`` and the ` +
+ ); + } +} +``` + +```jsx +ReactDOM.render(, document.getElementById('root')); +``` + +< !--tags: input,state,class -- > + +< !--expertise: 0 -- > +