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

fix: improve warning for deprecated equalityFn #1976

Merged
merged 3 commits into from Aug 6, 2023
Merged

Conversation

dai-shi
Copy link
Member

@dai-shi dai-shi commented Aug 5, 2023

Related Issues or Discussions

#1937 (reply in thread)
#1937 (reply in thread)
#1937 (comment)

Follow-up #1945

Summary

Improve the warning message based on the feedback.

Check List

  • yarn run prettier for formatting code and docs

@vercel
Copy link

vercel bot commented Aug 5, 2023

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

Name Status Preview Comments Updated (UTC)
zustand-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2023 1:18pm

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 5, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 439a73b:

Sandbox Source
React Configuration
React Typescript Configuration
React Browserify Configuration
React Snowpack Configuration
React Parcel Configuration
Next.js Configuration
@pavlobu/zustand demo Configuration

@github-actions
Copy link

github-actions bot commented Aug 5, 2023

Size Change: +268 B (+1%)

Total Size: 43.5 kB

Filename Size Change
dist/esm/index.js 706 B +66 B (+10%) ⚠️
dist/index.js 868 B +65 B (+8%) 🔍
dist/system/index.development.js 873 B +73 B (+9%) 🔍
dist/umd/index.development.js 999 B +64 B (+7%) 🔍
ℹ️ View Unchanged
Filename Size
dist/context.js 782 B
dist/esm/context.js 590 B
dist/esm/middleware.js 3.87 kB
dist/esm/middleware/immer.js 210 B
dist/esm/shallow.js 509 B
dist/esm/traditional.js 392 B
dist/esm/vanilla.js 629 B
dist/middleware.js 4.43 kB
dist/middleware/immer.js 328 B
dist/shallow.js 1.11 kB
dist/system/context.development.js 697 B
dist/system/context.production.js 386 B
dist/system/index.production.js 402 B
dist/system/middleware.development.js 4 kB
dist/system/middleware.production.js 2.62 kB
dist/system/middleware/immer.development.js 292 B
dist/system/middleware/immer.production.js 187 B
dist/system/shallow.development.js 558 B
dist/system/shallow.production.js 344 B
dist/system/traditional.development.js 505 B
dist/system/traditional.production.js 342 B
dist/system/vanilla.development.js 672 B
dist/system/vanilla.production.js 310 B
dist/traditional.js 433 B
dist/umd/context.development.js 887 B
dist/umd/context.production.js 556 B
dist/umd/index.production.js 543 B
dist/umd/middleware.development.js 4.58 kB
dist/umd/middleware.production.js 2.97 kB
dist/umd/middleware/immer.development.js 482 B
dist/umd/middleware/immer.production.js 342 B
dist/umd/shallow.development.js 1.23 kB
dist/umd/shallow.production.js 883 B
dist/umd/traditional.development.js 613 B
dist/umd/traditional.production.js 447 B
dist/umd/vanilla.development.js 800 B
dist/umd/vanilla.production.js 410 B
dist/vanilla.js 683 B

compressed-size-action

Comment on lines -50 to 61
if (import.meta.env?.MODE !== 'production' && equalityFn) {
if (
import.meta.env?.MODE !== 'production' &&
equalityFn &&
!didWarnAboutEqualityFn
) {
console.warn(
"[DEPRECATED] Use `createWithEqualityFn` from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"
"[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"
)
didWarnAboutEqualityFn = true
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be a good idea to extract this to equalityFn && warnAboutEqualityFnOnce()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, that doesn't work with minification/dead-code-elimination in production.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I don't have any more suggestions then.

@dai-shi
Copy link
Member Author

dai-shi commented Aug 6, 2023

I'm still waiting for some 👍 feedback in #1937.
Will merge it anyway tomorrow or so.

@dai-shi dai-shi merged commit a10dd1c into main Aug 6, 2023
33 checks passed
@dai-shi dai-shi deleted the fix/deprecation-warning branch August 6, 2023 23:26
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.

None yet

2 participants