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

Are we supposed to use memo wrapping while using jotai ..? #324

Closed
sahilrajput03 opened this issue Feb 28, 2021 · 6 comments
Closed

Are we supposed to use memo wrapping while using jotai ..? #324

sahilrajput03 opened this issue Feb 28, 2021 · 6 comments

Comments

@sahilrajput03
Copy link

since if we don't wrap components around React.memo, react re-renders all child components by default, is there some recommendations for using react.memo around each component for using jotai effectively.?

Jotai is great work, but i also made a similar thing some time ago when i din't know about it then.. https://www.npmjs.com/package/usewhat , but its far different thing from jotai, thanks!!

Loving uisng jotai!!

@Aslemammad
Copy link
Member

There's nothing bad about re-rendering. It will be bad if it decreases performance. You can use the memo there, and maybe there are other approaches instead of the memo. I recommend you this. But I'd love to see where's the problem in jotai and your performance so that we can help you more.

@dai-shi
Copy link
Member

dai-shi commented Feb 28, 2021

@sahilrajput03
In general, I'm not against using React.memo, it works well in some cases. I'd use it when useState has an array of objects.
With jotai, it's likely that we useAtom in deep in component tree, and it's less likely we need React.memo for performance optimization. If you organize the structure well, you would never need it.
Let me know if you have more specific questions. Happy to help.

@sahilrajput03
Copy link
Author

sahilrajput03 commented Feb 28, 2021

There's nothing bad about re-rendering. It will be bad if it decreases performance. You can use the memo there, and maybe there are other approaches instead of the memo. I recommend you this. But I'd love to see where's the problem in jotai and your performance so that we can help you more.

Gonna read this article and get back to you..., thanks for replying ..:)

#but some people do say that you must use react.memo as comparing dom nodes while checking if dom needs updation is more intensive than comparing props(react.memo) in any app.

I do understands that profiling is the best way if something needs render minimazation though..i am little confused.., will read the article by dan abramov and will get back here..!.

@sahilrajput03
Copy link
Author

@sahilrajput03
In general, I'm not against using React.memo, it works well in some cases. I'd use it when useState has an array of objects.
With jotai, it's likely that we useAtom in deep in component tree, and it's less likely we need React.memo for performance optimization. If you organize the structure well, you would never need it.
Let me know if you have more specific questions. Happy to help.

I just came to know about jotai from reading kent'c article about statemanagement.., but i am using this for my curren projects.., i am tired of making all contexts and their providers using usecontext.. 🤣

Thanks a lot for making jotai this good..!
:)

@dai-shi
Copy link
Member

dai-shi commented Mar 1, 2021

Check my latest todos example, using memo.
https://codesandbox.io/s/jotai-todos-ijyxm?file=/src/App.tsx:961-998

@sahilrajput03
Copy link
Author

I saved that codesandbox in my folder in codesandbox account, and will analy it sooner.
Thanks @dai-shi , i appreciate your work!

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

3 participants