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 Example (Persist API): Avoid 'any', avoid "might be null" error and make example clearer #1957

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

itayperry
Copy link
Contributor

@itayperry itayperry commented Jul 25, 2023

Related Issues or Discussions

#1955

This is a small fix for one of the examples in the docs (persist API).
The example:
image
Link: https://docs.pmnd.rs/zustand/integrations/persisting-store-data#how-do-i-use-it-with-map-and-set

Fixes

Fixes TypeScript Error in this example and clarifies a certain type that isn't really any.

Summary

The type of newValue isn't exactly StorageValue<any> but StorageValue<YourStateType>.
This PR helps to clarify that and helps users have better types.
In addition, str in getItem could be null and that's why this code won't compile.

zustand is incredible and I do not wish to waste your time, I just thought this might help 💛

@vercel
Copy link

vercel bot commented Jul 25, 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 Jul 25, 2023 8:29pm

@codesandbox-ci
Copy link

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 cba2dc4:

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

Copy link
Collaborator

@chrisk-7777 chrisk-7777 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 to me. Much clearer example overall - thanks!

@dai-shi dai-shi merged commit c5e7c30 into pmndrs:main Jul 26, 2023
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.

3 participants