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

docs - Added a note in how-tos/reset on how to use structuredClone #947

Merged
merged 8 commits into from
Sep 14, 2024

Conversation

overthemike
Copy link
Contributor

Related Bug Reports or Discussions

N/A
Fixes #
N/A

Summary

Added example on how to use structuredClone in v2 and the reasoning behind why it's different than v1.

Check List

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

Copy link

vercel bot commented Sep 13, 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 Sep 14, 2024 4:41am

Copy link

codesandbox-ci bot commented Sep 13, 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 Sep 13, 2024

@@ -34,3 +34,36 @@ const reset = () => {
state.obj = _.cloneDeep(initialObj)
Copy link
Member

Choose a reason for hiding this comment

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

I mean this is wrong too. L31-35

Can you please fix the doc in this way?

  • Fix cloneDeep usage with v2.
  • Add a note about structuredClone

Speaking of v2, we now have deepClone from valtio/utils, we don't need to use cloneDeep.
So, we could restructure the docs to use deepClone first and structuredClone second.
(I thought about explaining structuredClone first, but deepClone is capable of avoid copying ref()'d object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing. I'll push up the changes soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes have been pushed. Let me know of any feedback.

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 perfect!

@dai-shi dai-shi merged commit d30dddd into pmndrs:main Sep 14, 2024
28 checks passed
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