-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: zustand 설치 #21
feat: zustand 설치 #21
Conversation
const useCount = create<CountState>()( | ||
devtools((set) => ({ | ||
count: 0, | ||
increaseCount: () => set((state) => ({ count: state.count + 1 })), | ||
})) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여담으로 아래와 같이 devtools가 prod 환경에서만 실행됐음 좋겠다는 생각으로 구현하다가 타입에러문제를 해결하지 못해서 삭제했습니다 😂😂
const hoc = (callback) => {
return process.env.NODE_ENV !== 'production' ? devtools(callback) : callback;
};
const useCount = create<CountState>()(
hoc((set) => ({
count: 0,
increaseCount: () => set((state) => ({ count: state.count + 1 })),
}))
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
따로 hoc 방식으로 안해도 될 것 같아요!
찾아보니깐, prod에선 자동으로 제거된다네요~
만약 직접 끄고 싶으면 devtools(creator, { enabled: true })
옵션이 있다고 합니다
pmndrs/zustand#880
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prod에선 자동으로 제거된다니 다행이네요! 감사합니다 🙇🏻♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ㅋㅋprod환경에선 실행 안됐으면 하셨다는거죠!? 후후
그냥 여담인데, hoc 방식을 적극적으로 사용하시나요?? (단순 궁금증입니다!!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
음 저는 hoc 방식을 적극적으로 사용하진않고 필요할때마만 가끔 씁니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm~ 👍
const useCount = create<CountState>()( | ||
devtools((set) => ({ | ||
count: 0, | ||
increaseCount: () => set((state) => ({ count: state.count + 1 })), | ||
})) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
따로 hoc 방식으로 안해도 될 것 같아요!
찾아보니깐, prod에선 자동으로 제거된다네요~
만약 직접 끄고 싶으면 devtools(creator, { enabled: true })
옵션이 있다고 합니다
pmndrs/zustand#880
LGTM~~!!! 작업 넘 감사드립니다!!! |
이슈 번호
#17
작업 분류
작업 상세 내용
share/store/useXXX.ts
로 여러개의 스토어를 두는 방식으로 사용하려고 하는데 괜찮은지 궁금합니다! (현재 사용법은 store를 context별로 나누어 사용하는데 context를 구분지을 provider도 없고 무분별하게 사용할 수 있어서 이게 맞는건가 고민이 됩니다?)