Skip to content

Fix hooks-faq.md, unnecessary dependency in example? - #615

Closed
uid11 wants to merge 1 commit into
reactjs:masterfrom
uid11:patch-4
Closed

Fix hooks-faq.md, unnecessary dependency in example?#615
uid11 wants to merge 1 commit into
reactjs:masterfrom
uid11:patch-4

Conversation

@uid11

@uid11 uid11 commented Mar 11, 2021

Copy link
Copy Markdown
Contributor

If I understand correctly the intended API of the useEventCallback custom hook, the dependencies array should contain all the dependencies of the fn callback itself (as in the standard useCallback hook).

Thus, there is no need to additionally specify the fn callback itself in the dependencies of this effect -- you need to update the link to fn in the ref only when something from the dependencies array changes.

Moreover, now, due to the fact that fn is specified in the effect dependencies, this effect is called after every render of the Form -- since fn, as an arrow function literal, is created on every render.

@netlify

netlify Bot commented Mar 11, 2021

Copy link
Copy Markdown

Deploy preview for ru-reactjs ready!

Built with commit 378e608

https://deploy-preview-615--ru-reactjs.netlify.app

@uid11

uid11 commented Mar 11, 2021

Copy link
Copy Markdown
Contributor Author

Видимо, предлагать правки в коде примеров нужно в основном репозитории документации, а не в переводе, поэтому закрыл в пользу reactjs/react.dev#3573.

@uid11 uid11 closed this Mar 11, 2021
@ntishkevich

Copy link
Copy Markdown
Contributor

Видимо, предлагать правки в коде примеров нужно в основном репозитории документации, а не в переводе, поэтому закрыл в пользу reactjs/reactjs.org#3573.

Все верно, правки кода лучше предложить в основном репозитории документации. Как только их там примут, нам прилетит PR от бота на синхронизацию изменений.

@uid11
uid11 deleted the patch-4 branch March 14, 2021 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants