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

Zustand version #102

Open
DavoCg opened this issue Mar 19, 2024 · 1 comment
Open

Zustand version #102

DavoCg opened this issue Mar 19, 2024 · 1 comment

Comments

@DavoCg
Copy link

DavoCg commented Mar 19, 2024

Hello,

This package is using an old zustand version and this message [DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use import { useStore } from 'zustand'.

Would you consider upgrading to last zustand version and using import { createStore } from "zustand" instead of import create from "zustand/vanilla";

Instead of

export default function createStore() {
  return create<FeedStoreState>((set) => ({

It would like

export default function createFeedStore() {
  return createStore<FeedStoreState>()((set) => ({

I consumer land it would be used like:

import { useStore } from "zustand";

const count = useStore(feed.store, (state) => state.metadata.unseen_count);

This modification would require some changes in feed code,

Happy to submit a PR if you consider it and don't hesitate to tell me if i miss something

@mohammadzeyghami
Copy link

mohammadzeyghami commented Mar 20, 2024

hey test this syntax

import { create } from "zustand";

interface CounterStore {
count: number | string;
setCount: (item: string | number) => void;
}
export const useCounterStore = create((set) => ({
count: 0,
setCount: (item) => {
set({ count: item });
},
}));

in your component
const { count , setCount } = useCounterStore();

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

No branches or pull requests

2 participants