Tell us what’s happening:
Someone can help me please with this challenge ? I’m trying to do it with normal javascript ‘if’, but it seems like I don’t right well the code to make the border = 3px solid red. What did I do wrong ? Thank you
**Your 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) {
return 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>
);
}
};
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15
Challenge: React - Change Inline CSS Conditionally Based on Component State
Thanks you, I just passed the challenge thanks to your help. Is there any way to do it with ternary operator ??? I tried this but it doesn’t work of course =>this.state.input.length > 15 ? inputStyle.border= 3px solid red
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.