Skip to content

Instantly share code, notes, and snippets.

@ovpv
Created September 2, 2019 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ovpv/789f1670cb85400935b564386bf699a2 to your computer and use it in GitHub Desktop.
Save ovpv/789f1670cb85400935b564386bf699a2 to your computer and use it in GitHub Desktop.
Meter component to show the password strength
class Meter extends React.Component{
constructor(){
super();
this.state={
status: "low"
}
}
componentDidUpdate(prevprops,state){
this.changeStatus(this.props.value);
}
changeStatus = (value) => {
switch(value){
case 10:
this.setState({
status: "low"
})
break;
case 50:
this.setState({
status: "medium"
})
break;
case 100:
this.setState({
status: "high"
})
break;
}
}
render(){
return (
<span className={`progress ${this.state.status}`}></span>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment