Skip to content

Commit 48b2d17

Browse files
merging all conflicts
2 parents b726491 + e3cf542 commit 48b2d17

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

content/blog/2018-06-07-you-probably-dont-need-derived-state.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ To recap, when designing a component, it is important to decide whether its data
213213
Instead of trying to **"mirror" a prop value in state**, make the component **controlled**, and consolidate the two diverging values in the state of some parent component. For example, rather than a child accepting a "committed" `props.value` and tracking a "draft" `state.value`, have the parent manage both `state.draftValue` and `state.committedValue` and control the child's value directly. This makes the data flow more explicit and predictable.
214214

215215
For **uncontrolled** components, if you're trying to reset state when a particular prop (usually an ID) changes, you have a few options:
216-
* **Recomendation: To reset _all internal state_, use the `key` attribute.**
216+
* **Recommendation: To reset _all internal state_, use the `key` attribute.**
217217
* Alternative 1: To reset _only certain state fields_, watch for changes in a special property (e.g. `props.userID`).
218218
* Alternative 2: You can also consider fall back to an imperative instance method using refs.
219219

content/docs/hooks-reference.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ You can also create the initial state lazily. To do this, you can pass an `init`
233233

234234
It lets you extract the logic for calculating the initial state outside the reducer. This is also handy for resetting the state later in response to an action:
235235

236-
```js{1-3,11-12,21,26}
236+
```js{1-3,11-12,19,24}
237237
function init(initialCount) {
238238
return {count: initialCount};
239239
}
@@ -247,9 +247,13 @@ function reducer(state, action) {
247247
case 'reset':
248248
return init(action.payload);
249249
default:
250+
<<<<<<< HEAD
250251
// Un reducer siempre debe devolver un estado válido.
251252
// Alternativamente, puede lanzar un error si se envía una acción no válida.
252253
return state;
254+
=======
255+
throw new Error();
256+
>>>>>>> e3cf542e75018ff7f0104ab7a4df9dc2b8d43bef
253257
}
254258
}
255259

0 commit comments

Comments
 (0)