Skip to content

Added ellipsis to indicate incomplete code snippet #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions content/docs/lifting-state-up.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class TemperatureInput extends React.Component {

render() {
const temperature = this.state.temperature;
// ...
```

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.
Expand All @@ -182,6 +183,7 @@ First, we will replace `this.state.temperature` with `this.props.temperature` in
render() {
// Before: const temperature = this.state.temperature;
const temperature = this.props.temperature;
// ...
```

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.
Expand All @@ -194,6 +196,7 @@ Now, when the `TemperatureInput` wants to update its temperature, it calls `this
handleChange(e) {
// Before: this.setState({temperature: e.target.value});
this.props.onTemperatureChange(e.target.value);
// ...
```

>Note:
Expand Down