Answer the question
In order to leave comments, you need to log in
What do they write in brackets {} in the render function in react?
The documentation explains why they write code in the render function between { } rather superficially. It says that the { } code is written in curly braces so that JSX understands that this is JavaScript. Or they write that you can write a JS expression in brackets. But expressions in my understanding are something like this: a= b+c or a=b.
And I often see that in curly brackets they write just one word and that's it. Here are some examples:
render() {
return (
<WeatherDisplay
key={activePlace} // ВОТ ЗДЕСЬ
zip={PLACES[activePlace].zip} //ИЛИ ЗДЕСЬ
/>
</div>
);
}
render() {
const { isActive } = this.state; // И ЕЩЕ
return (
<div>
<button onClick={handleClick}>Try it</button> // И ВОТ
<div className={isActive ? 'mystyle' : ''}>
This is a DIV element.
</div>
</div>
);
}
}
Answer the question
In order to leave comments, you need to log in
in my understanding it is something like this: a= b+c or a=b.
const a = 1;
a; // это выражение
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question