Skip to content
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

React computed state example should use useMemo hook #181

Closed
Lsnsh opened this issue Aug 2, 2023 · 2 comments
Closed

React computed state example should use useMemo hook #181

Lsnsh opened this issue Aug 2, 2023 · 2 comments

Comments

@Lsnsh
Copy link

Lsnsh commented Aug 2, 2023

image

https://react.dev/reference/react/useMemo

image

https://vuejs.org/guide/essentials/computed.html#computed-caching-vs-methods

image

In actual coding, if only have some easy calculate, use expression is better, because hook also have expenses

@matschik
Copy link
Owner

matschik commented Aug 2, 2023

Duplicate #120

@matschik matschik closed this as completed Aug 2, 2023
@matschik
Copy link
Owner

matschik commented Aug 2, 2023

Other examples don't use memoization. If you want useMemo to be featured, please check out this issue: #122
In the computed snippet, using memoization makes no sense. It's over optimization.

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

No branches or pull requests

2 participants