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

State is deprecated, but still used in Docs #2024

Closed
dinogomez opened this issue Sep 2, 2023 · 17 comments
Closed

State is deprecated, but still used in Docs #2024

dinogomez opened this issue Sep 2, 2023 · 17 comments
Labels
documentation Improvements or additions to documentation

Comments

@dinogomez
Copy link

Summary

State is deprecated but is still shown and used in the docs.
image

Docs

image

Link to reproduction

https://docs.pmnd.rs/zustand/guides/updating-state

https://github.com/pmndrs/zustand/blob/main/docs/guides/updating-state.md

@dai-shi
Copy link
Member

dai-shi commented Sep 3, 2023

Would you like to open a PR to fix it?

@dai-shi dai-shi added the documentation Improvements or additions to documentation label Sep 3, 2023
@OshriAsulin
Copy link
Contributor

Hi @dai-shi , I will be happy to open pr of this issue but really I didn't understanding the bug

@OshriAsulin
Copy link
Contributor

I thinking @dinogomez got this error because it didn't create this next type in the image

צילום מסך 2023-09-03 130822

@dai-shi
Copy link
Member

dai-shi commented Sep 3, 2023

I'm not sure either but there remains deprecated State type from zustand in docs, right?

@OshriAsulin
Copy link
Contributor

OshriAsulin commented Sep 3, 2023

Right @dai-shi , he remains the docs, but I checked this issue and I worked according to the docs and I didn't get this as an error

My test:

צילום מסך 2023-09-03 132713 צילום מסך 2023-09-03 132736

@dai-shi
Copy link
Member

dai-shi commented Sep 3, 2023

It looks good.

@dinogomez
Copy link
Author

Hi @dai-shi and @OshriAsulin , I am just starting to learn Zustand and Typescript, so I wont be able to help much. I just noticed the deprecation warning when I was following the docs in vscode.

After following Oshi's reproduction I found that it was because I used a different name for state i.e userState that caused it.
image

After I renamed it properly it worked without warnings.

image

So the docs were fine, it was just a mistake on my end. Sorry for taking moments of your time and thank you for the help as well. Since everything is good ill be closing the issue. Working with zustand is such a good dev experience and really helped me with my state management issues. Cheers!

@dai-shi
Copy link
Member

dai-shi commented Sep 3, 2023

Okay, so there are no deprecated State types remained in docs.

@OshriAsulin
Copy link
Contributor

OshriAsulin commented Sep 3, 2023

Right, but I founded another issue in this is snnipet code-
Please describe what you expected to happen when using the shallow in this example from the docs-

image

This example is from the links from the top of this page.

when I tried to use it I got an error-
צילום מסך 2023-09-03 133301

@OshriAsulin
Copy link
Contributor

And when I hide this shallow is working fine
image

@OshriAsulin
Copy link
Contributor

I will happy to work on this issue @dai-shi let me to know if I can to do that.

@dai-shi
Copy link
Member

dai-shi commented Sep 3, 2023

shallow should be there, because the selector L26 creates a new array. Not sure what is your suggestion about improving the description, but please feel free to open a PR and discuss based on it (though, in the end we may decide not to merge.)

@OshriAsulin
Copy link
Contributor

I mean for improving, because the shallow is making an error so remove him from the example of the docs.
@dai-shi

@dai-shi
Copy link
Member

dai-shi commented Sep 4, 2023

Do you mean adding import { shallow } from 'zustand/shallow' improves it?

@OshriAsulin
Copy link
Contributor

OshriAsulin commented Sep 4, 2023

Do you mean adding import { shallow } from 'zustand/shallow' improves it?

Yes, It's resolved the issue. @dai-shi

But it does not exist in the docs

Untitled.video.-.Made.with.Clipchamp.2.mp4

@OshriAsulin
Copy link
Contributor

So I thought about two options-
1 Add the imports to create and to shalllow as in the following example -

import { create } from 'zustand'
import { shallow } from 'zustand/shallow'

2 Remove the shallow to avoid user errors

@dai-shi let me to know which solution you want I implement?

@dai-shi
Copy link
Member

dai-shi commented Sep 5, 2023

Add import statements, because removing shallow is wrong (even if the error seems to go away.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants