Skip to content

Commit

Permalink
add : zustand 설치 및 예제파일 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
banhogu committed May 14, 2024
1 parent c688535 commit d092f2e
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
38 changes: 37 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"react-markdown": "^9.0.1",
"react-query": "^3.39.3",
"react-toastify": "^10.0.5",
"remark-gfm": "^4.0.0"
"remark-gfm": "^4.0.0",
"zustand": "^4.5.2"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.13",
Expand Down
22 changes: 22 additions & 0 deletions src/store/example.store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';

//기본 사용법 타입 에러는 일단 무시

let userStore = (set) => ({
user: null,
setUser: (payload) =>
set((state) => ({

Check warning on line 9 in src/store/example.store.ts

View workflow job for this annotation

GitHub Actions / Lint

'state' is defined but never used

Check failure on line 9 in src/store/example.store.ts

View workflow job for this annotation

GitHub Actions / Lint

'state' is defined but never used
user: payload.data
}))
});

// redux devtools처럼 chrome 확장자 앱 사용해서 사용가능
userStore = devtools(userStore);

// persist 새로고침시 데이터 유지
userStore = persist(userStore, {
name: 'userStore'
});

export const userStore = create(userStore);

0 comments on commit d092f2e

Please sign in to comment.