So, I’m getting this error!!!
The input tag should be styled with a border of 3px solid red if the input value in state is longer than 15 characters.
My code so far
class GateKeeper extends React.Component {
constructor(props) {
super(props);
this.state = {
input: ''
};
this.handleChange = this.handleChange.bind(this);
}
handleChange(event) {
this.setState({ input: event.target.value })
}
render() {
let inputStyle = {
border: '1px solid black'
};
// change code below this line
if (this.state.input.length >= 15) {
inputStyle = {
border: ' 3px solid red'
}
}
// change code above this line
return (
<div>
<h3>Don't Type Too Much:</h3>
<input
type="text"
style={inputStyle}
value={this.state.input}
onChange={this.handleChange} />
</div>
);
}
};
Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/change-inline-css-conditionally-based-on-component-state