-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / Lint
|
||
user: payload.data | ||
})) | ||
}); | ||
|
||
// redux devtools처럼 chrome 확장자 앱 사용해서 사용가능 | ||
userStore = devtools(userStore); | ||
|
||
// persist 새로고침시 데이터 유지 | ||
userStore = persist(userStore, { | ||
name: 'userStore' | ||
}); | ||
|
||
export const userStore = create(userStore); |