Skip to content

Commit 27159e1

Browse files
author
Nick Charbonneau
committed
Fix line highlights
1 parent 83f30a8 commit 27159e1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/react/9-managing-complex-state.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ In React, `props` are the "arguments" that are passed to our component. Alternat
1111

1212
Use `state` for internal variables, which when changed, should re-render the component. Examples include the value of a text box, whether or not a modal is open, and the current tab selection.
1313

14-
Using functional components, the `useState()` hook provides a value and setter capable of holding any data type. (We will explain hooks in more detail in the coming lessons. For now, don't worry about what exactly a hook is.) This allows us to hold simple variables such as:
14+
Using functional components, the `useState()` hook provides a value and setter capable of holding any data type. This allows us to hold simple variables such as:
1515

1616
```js
1717
const [count, setCount] = useState(0);
@@ -126,7 +126,7 @@ function WrapperContainer() {
126126
}
127127
```
128128

129-
@highlight 3,5,10-14,17
129+
@highlight 3,5,10-14
130130

131131
Using this data in the `DisplayComponent` is simple. Use the props to render the component and call `setUnsavedText` on changes.
132132

@@ -153,7 +153,9 @@ Next, let's wire up that button. We'll define an `onButtonClick` callback to han
153153

154154
```jsx
155155
function WrapperContainer() {
156+
// define the savedText to be shown
156157
const [savedText, setSavedText] = useState('');
158+
// create a holder for unsaved text
157159
const [unsavedText, setUnsavedText] = useState('');
158160

159161
function onButtonClick() {
@@ -180,7 +182,7 @@ function WrapperContainer() {
180182
}
181183
```
182184

183-
@highlight 2-3,5-10,15-19,22
185+
@highlight 7-12, 24
184186

185187
Lastly, update the `ButtonComponent` to use our new callback.
186188

@@ -255,7 +257,7 @@ ReactDOM.render(<WrapperContainer />, document.getElementById('root'));
255257
```
256258

257259
@codepen react
258-
@highlight 5,7,9-14,19-23,26,32,33-36,40,42,47,49
260+
@highlight 2-5,7-12,17-21,24,30-34,38,40,47-49
259261

260262
## What data should be kept in React state?
261263

0 commit comments

Comments
 (0)