Skip to content

fix(performance): improve useArrayProp memoization#1470

Open
stipsan wants to merge 1 commit into
mainfrom
auto-memoize-portal-provider
Open

fix(performance): improve useArrayProp memoization#1470
stipsan wants to merge 1 commit into
mainfrom
auto-memoize-portal-provider

Conversation

@stipsan

@stipsan stipsan commented Nov 11, 2024

Copy link
Copy Markdown
Member

Follows the principles detailed in this thread: react/react#31330 (comment)

While at it I cleaned up useArrayProp, which internally seems to never actually use defaultValue. Since the hook is exported I've added a compat hook in src/core/hooks/useArrayPropLegacy.ts so that third party libraries that make use of the useArrayProp(value, defaultValue) pattern continue working.
They'll get a deprecated warning though and tell them to migrate to useArrayProp(value ?? defaultValue).

This PR also takes care of the linter warning for useUnique inside src/core/utils/portal/portalProvider.tsx

@vercel

vercel Bot commented Nov 11, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sanity-ui-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 11, 2024 11:05pm
sanity-ui-workshop ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 11, 2024 11:05pm

@justshiv

Copy link
Copy Markdown

@stipsan hello! Would you still like to add this improvement?

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