added useMemo to the Memoize NetworkContext.jsx#48
added useMemo to the Memoize NetworkContext.jsx#48aniket866 wants to merge 1 commit intoDjedAlliance:mainfrom
Conversation
📝 WalkthroughWalkthroughNetworkContext.jsx received performance optimizations using React hooks: useCallback wrapped four callback functions (resetState, selectNetwork, selectToken, resetSelections) and useMemo wrapped the provider value object to prevent unnecessary re-renders. A new public hook useNetwork() was exported for context access. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Key Effects:
Eliminates Wasted Re-renders: Wrapping the Context value in useMemo ensures that consuming components (like Widget and TransactionReview) only re-render when actual data changes, rather than on every parent render cycle.
Stabilizes Function References: Implementing useCallback for selectNetwork, selectToken, and resetSelections prevents these functions from being recreated on every render, maintaining stable identities for dependency checks.
Standardizes Context Pattern: Aligns the context provider with React best practices for high-frequency updates, reducing the overall CPU and memory footprint of the SDK widget.
Wrap context value in useMemo to maintain referential stability
@Zahnentferner Please checkout this Improvement, If any issue let me know I will fix that . Closes #43
Summary by CodeRabbit
New Features
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.