Files
2018-10-16 21:32:40 +05:30

38 lines
1018 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Render Conditionally from Props
localeTitle: Отказывать условно от реквизита
---
## Отказывать условно от реквизита
Это немного сложно, но легко.
## Решение
Измените `handleClick()` с правильной инструкцией по увеличению.
```react.js
handleClick() {
this.setState({
counter: this.state.counter + 1
});
}
```
В методе `render()` используйте `Math.random()` как указано в описании задачи, и напишите тернарное выражение, чтобы передать `props` в компоненте **Results** .
```react.js
let expression = Math.random() > .5;
{(expression == 1)? <Results fiftyFifty="You win!"/> : <Results fiftyFifty="You lose!"/> }
```
Затем `fiftyFifty` реквизит в компоненте Results.
```react.js
<h1>
{
this.props.fiftyFifty
}
</h1>
```