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

immer example for createSliceWithImmer #26

Merged
merged 7 commits into from
Jul 11, 2024

Conversation

Ebubekir-Tas
Copy link
Contributor

Example case for createSlicesWithImmer

Also primitives values for slices can be used with explicit returns that do not modify the draft state as shown in textSlice so that's nice

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
Copy link

codesandbox-ci bot commented Jul 10, 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
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.

Can you add entries in package.json and README.md too?
Find how 03_actions is configured there.

"version": "0.0.0",
"private": true,
"type": "module",
"dependencies": {
Copy link
Member

Choose a reason for hiding this comment

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

We need "immer" too.

Copy link
Contributor Author

@Ebubekir-Tas Ebubekir-Tas Jul 10, 2024

Choose a reason for hiding this comment

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

I added immer as a dependency in the examples folder, I need to also add

    "examples:01_counter": "DIR=01_counter vite",
    "examples:02_async": "DIR=02_async vite",
    "examples:03_actions": "DIR=03_actions vite",
    "examples:04_immer": "DIR=04_immer vite"

to the root package.json but it seems something desynced my local branch to this pull request and I'm hesitant to make any force pushes (fixed)

I ran the example locally and it worked fine. Noteworthy that to run it in windows the script is

"examples:04_immer": "set DIR=04_immer&& vite"

edit: I also see stackblitz URLs in the README, but the new createSliceWithImmer method right now isn't included in the latest published version on NPM so it isn't yet accessible without a local clone using npm link so the method is not accessible on stackblitz right now

@dai-shi
Copy link
Member

dai-shi commented Jul 11, 2024

I also see stackblitz URLs in the README

It will run when we release a new version. But, I can update README later.

Noteworthy that to run it in windows the script is

I'm wondering if this works for windows users: https://pnpm.io/cli/run#shell-emulator

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.

LGTM!

@dai-shi dai-shi merged commit b4e86e6 into zustandjs:main Jul 11, 2024
2 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