Skip to content

Commit

Permalink
#21 Feat: userState 아톰 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
yunseul-dev committed Dec 7, 2023
1 parent 9c8e72b commit 8c85bad
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/recoil/atom/userState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { atom } from 'recoil';

const userState = atom({
key: 'userState',
default: JSON.parse(localStorage.getItem('userState') || '{}'),
effects_UNSTABLE: [
({ onSet }) => {
onSet(newUser => {
localStorage.setItem('userInfo', JSON.stringify(newUser));
});
},
],
});

export default userState;

0 comments on commit 8c85bad

Please sign in to comment.