Skip to content

Commit 23fac76

Browse files
Merge branch 'master' into patch-1
2 parents 52dfde1 + a201113 commit 23fac76

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

content/docs/lifting-state-up.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ class TemperatureInput extends React.Component {
166166
167167
render() {
168168
const temperature = this.state.temperature;
169-
}
170-
}
169+
// ...
171170
```
172171

173172
However, we want these two inputs to be in sync with each other. When we update the Celsius input, the Fahrenheit input should reflect the converted temperature, and vice versa.
@@ -184,7 +183,7 @@ First, we will replace `this.state.temperature` with `this.props.temperature` in
184183
render() {
185184
// Before: const temperature = this.state.temperature;
186185
const temperature = this.props.temperature;
187-
}
186+
// ...
188187
```
189188

190189
We know that [props are read-only](/docs/components-and-props.html#props-are-read-only). When the `temperature` was in the local state, the `TemperatureInput` could just call `this.setState()` to change it. However, now that the `temperature` is coming from the parent as a prop, the `TemperatureInput` has no control over it.
@@ -197,7 +196,7 @@ Now, when the `TemperatureInput` wants to update its temperature, it calls `this
197196
handleChange(e) {
198197
// Before: this.setState({temperature: e.target.value});
199198
this.props.onTemperatureChange(e.target.value);
200-
}
199+
// ...
201200
```
202201

203202
>Note:

0 commit comments

Comments
 (0)