일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- Promise
- 무한 스크롤
- 공변성
- autosize
- 타입 좁히기
- async/await
- app router
- 결정 알고리즘
- 인터섹션
- MSA
- tailwind
- 투포인터
- RTK Query
- 태그된 유니온
- CI/CD
- dfs
- recoil
- CORS
- ESlint
- map
- webpack
- useAppDispatch
- 호이스팅
- React
- SSR
- 리터럴 타입
- TS
- 인증/인가
- Jest
- 반공변성
Archives
- Today
- Total
짧은코딩
react-cookie 본문
반응형
react-cookie
react-cookie는 쿠키를 만들어 줄 수 있는 라이브러리이다.
-npm 사이트
https://www.npmjs.com/package/react-cookie
react-cookie
Universal cookies for React. Latest version: 4.1.1, last published: a year ago. Start using react-cookie in your project by running `npm i react-cookie`. There are 505 other projects in the npm registry using react-cookie.
www.npmjs.com
npm i react-cookie
이 명령어로 다운 받을 수 있다.
적용
-utills/cookie.ts
import { Cookies } from "react-cookie";
const cookies = new Cookies();
export const setCookie = (name: string, value: string, option?: any) => {
return cookies.set(name, value, { ...option });
};
export const getCookie = (name: string) => {
return cookies.get(name);
};
setCookie: 새로운 쿠키를 생성할 수 있다.
getCookie: 쿠키의 이름을 가져올 수 있다.
-logIn.tsx
setCookie("a", "123");
이렇게 하면 쿠키가 생성된다.
반응형
'리액트' 카테고리의 다른 글
React 일정 숫자만큼 화면에 쓰는법 (0) | 2022.09.21 |
---|---|
react-router 5버전에서 뒤로가기 버튼 만들기(useHistory) (0) | 2022.09.11 |
X-Requested-With (0) | 2022.09.03 |
form 안에서 sumbit이 아닌 버튼이 요청이 갈 때 해결법 (1) | 2022.09.02 |
Property 'checkIdModal' does not exist on type 'JSX.IntrinsicElements'. 해결법 (0) | 2022.09.01 |
Comments