mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 04:12:34 +00:00
committed by
Alexey Pyltsyn
parent
7b217c7010
commit
dda5b49f45
@@ -201,7 +201,7 @@ Custom Hooks offer the flexibility of sharing logic that wasn't possible in Reac
|
||||
|
||||
Try to resist adding abstraction too early. Now that function components can do more, it's likely that the average function component in your codebase will become longer. This is normal -- don't feel like you *have to* immediately split it into Hooks. But we also encourage you to start spotting cases where a custom Hook could hide complex logic behind a simple interface, or help untangle a messy component.
|
||||
|
||||
For example, maybe you have a complex component that contains a lot of local state that is managed in an ad-hoc way. `useState` doesn't make centralizing the update logic any easier so might you prefer to write it as a [Redux](https://redux.js.org/) reducer:
|
||||
For example, maybe you have a complex component that contains a lot of local state that is managed in an ad-hoc way. `useState` doesn't make centralizing the update logic any easier so you might prefer to write it as a [Redux](https://redux.js.org/) reducer:
|
||||
|
||||
```js
|
||||
function todosReducer(state, action) {
|
||||
|
||||
Reference in New Issue
Block a user