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

fixed issue with .has() when new value is added and then deleted or c… #981

Merged
merged 9 commits into from
Oct 27, 2024

Conversation

overthemike
Copy link
Collaborator

…leared

Related Bug Reports or Discussions

#979
Fixes #
#979

Summary

Accessing this.index in the has method doesn't seem to work when a new item is added and then deleted (or cleared) at a later time. Accessing the this.data.length property fixes this issue.

Check List

  • [ x ] pnpm run prettier for formatting code and docs

Copy link

vercel bot commented Oct 23, 2024

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

Name Status Preview Comments Updated (UTC)
valtio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 26, 2024 7:40am

Copy link

codesandbox-ci bot commented Oct 23, 2024

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.

Copy link

pkg-pr-new bot commented Oct 23, 2024

Open in Stackblitz

More templates

pnpm add https://pkg.pr.new/valtio@981

commit: bab9c99

Copy link

github-actions bot commented Oct 23, 2024

Size Change: +49 B (+0.36%)

Total Size: 13.6 kB

Filename Size Change
./dist/esm/vanilla/utils.mjs 3.15 kB +25 B (+0.8%)
./dist/vanilla/utils.js 3.18 kB +24 B (+0.76%)
ℹ️ View Unchanged
Filename Size
./dist/esm/index.mjs 63 B
./dist/esm/react.mjs 691 B
./dist/esm/react/utils.mjs 257 B
./dist/esm/utils.mjs 68 B
./dist/esm/vanilla.mjs 2.34 kB
./dist/index.js 243 B
./dist/react.js 681 B
./dist/react/utils.js 278 B
./dist/utils.js 248 B
./dist/vanilla.js 2.37 kB

compressed-size-action

@overthemike overthemike marked this pull request as ready for review October 23, 2024 21:37
Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

Thanks for working on it. Is it possible to add a test?

src/vanilla/utils/proxyMap.ts Outdated Show resolved Hide resolved
Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

it probably requires more.

src/vanilla/utils/proxyMap.ts Outdated Show resolved Hide resolved
tests/proxyMap.test.tsx Show resolved Hide resolved
@overthemike
Copy link
Collaborator Author

Is there anything else that needs doing before this gets merged?

Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

Looks good overall.

src/vanilla/utils/proxyMap.ts Outdated Show resolved Hide resolved
tests/proxyMap.test.tsx Show resolved Hide resolved
Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

This causes extra rerenders with .has(), which doesn't seem ideal, but can't be helped. It's ironic that the use of .has() should be discouraged, even though proxyMap/Set should exist for performance.

@overthemike
Copy link
Collaborator Author

Yeah - .has() essentially needs to check if the value exists every time the data changes :\

@overthemike
Copy link
Collaborator Author

Are we waiting on anything to get this merged and get a patch version published?

@dai-shi dai-shi merged commit 13a59d8 into main Oct 27, 2024
29 checks passed
@dai-shi dai-shi deleted the 979 branch October 27, 2024 07:21
@dai-shi
Copy link
Member

dai-shi commented Oct 28, 2024

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