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

feat: zustand 설치 #21

Merged
merged 1 commit into from
Jan 30, 2023
Merged

feat: zustand 설치 #21

merged 1 commit into from
Jan 30, 2023

Conversation

sangbooom
Copy link
Collaborator

@sangbooom sangbooom commented Jan 29, 2023

이슈 번호

#17

작업 분류

  • 버그 수정
  • 신규 기능
  • 프로젝트 구조 변경

작업 상세 내용

  • zustand 패키지를 섪치했습니다.
  • share/store/useXXX.ts 로 여러개의 스토어를 두는 방식으로 사용하려고 하는데 괜찮은지 궁금합니다! (현재 사용법은 store를 context별로 나누어 사용하는데 context를 구분지을 provider도 없고 무분별하게 사용할 수 있어서 이게 맞는건가 고민이 됩니다?)
  • 좋은 사용법이 있다면 공유부탁드립니다! 그리고 이 방식이 문제점이 있다면 말씀부탁드립니다~

@sangbooom sangbooom requested a review from siyeons as a code owner January 29, 2023 12:07
@sangbooom sangbooom self-assigned this Jan 29, 2023
@sangbooom sangbooom requested a review from young-do as a code owner January 29, 2023 12:07
Comment on lines +10 to +15
const useCount = create<CountState>()(
devtools((set) => ({
count: 0,
increaseCount: () => set((state) => ({ count: state.count + 1 })),
}))
);
Copy link
Collaborator Author

@sangbooom sangbooom Jan 29, 2023

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 })),
  }))
);

Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

prod에선 자동으로 제거된다니 다행이네요! 감사합니다 🙇🏻‍♂️

Copy link
Member

Choose a reason for hiding this comment

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

ㅋㅋprod환경에선 실행 안됐으면 하셨다는거죠!? 후후
그냥 여담인데, hoc 방식을 적극적으로 사용하시나요?? (단순 궁금증입니다!!)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

음 저는 hoc 방식을 적극적으로 사용하진않고 필요할때마만 가끔 씁니다!

Copy link
Collaborator

@young-do young-do left a comment

Choose a reason for hiding this comment

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

lgtm~ 👍

Comment on lines +10 to +15
const useCount = create<CountState>()(
devtools((set) => ({
count: 0,
increaseCount: () => set((state) => ({ count: state.count + 1 })),
}))
);
Copy link
Collaborator

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

@siyeons
Copy link
Member

siyeons commented Jan 30, 2023

LGTM~~!!! 작업 넘 감사드립니다!!!

@sangbooom sangbooom merged commit 6dab376 into main Jan 30, 2023
@sangbooom sangbooom deleted the chore/zustand branch January 30, 2023 12:20
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