Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- python
- chrome
- 티스토리챌린지
- 코테
- Jenkins
- css
- AWS
- Express
- nuxt
- 코딩테스트
- nginx
- 광고 id
- kotlin
- toml
- 파이썬
- NanoHttpd
- 오퍼월
- spring boots
- EC2
- TypeScript
- docker
- Next
- it
- react-native
- JavaScript
- 오블완
- 백준
- 개발
- React
- Android
Archives
- Today
- Total
내맘대로 개발일지
[React] Antd DatePicker 한글 패치 하는 방법 본문
📱테스트 환경
"react": "18.3.0",
"react-dom": "18.3.0"
Antd DatePicker 를 사용하면 영어로 나온다.
이를 위해서 locale 을 한글로 바꿔주는 작업을 해야하는데
문서에 나와있는대로 바꾸면 반쪽짜리가 되는 이슈가 있을 것 이다.
import {ConfigProvider} from "antd";
import ko_KR from "antd/lib/locale/ko_KR";
<ConfigProvider locale={ko_KR}>
<App/>
</ConfigProvider>
이 뿐만 아니라 dayjs locale 도 한글로 바꿔줘야한다.
다른 블로그나 다른 곳에서 보면 moment 를 쓰라는 곳도 있지만
왠만하면 dayjs 를 사용할 수 있도록 하자.
이유는 여기서 보면 된다.
[React] Moment 대신 Day.js
📱테스트 환경"react": "18.3.0","react-dom": "18.3.0"이번에 Antd RangePicker 연결하면서 Dayjs 을 사용하는 것을보고오랜만에 잊고있었던 Day.js 가 생각나면서 흔히 사용하는 Moment 대신 사용하는이유를 다시
8735.tistory.com
아무튼 전체적인 코드를 확인해보면
import "./instrument";
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import {ConfigProvider} from "antd";
import ko_KR from "antd/lib/locale/ko_KR";
import dayjs from "dayjs";
import "dayjs/locale/ko";
dayjs.locale("ko");
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<ConfigProvider locale={ko_KR}>
<App/>
</ConfigProvider>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
이런식으로 작성하면 되는데
이렇게하면 한글패치가 완벽하게 된 데이트피커를 사용할 수 있다.
'Javascript > React' 카테고리의 다른 글
| [React] Warning: Each child in a list should have a unique "key" prop. (0) | 2025.03.10 |
|---|---|
| [React] Drag&Drop 을 위한 React-complex-tree (0) | 2024.12.19 |
| [React] JSX.Element 곧 사용할 수 없게 될 심볼이 사용되었습니다 (0) | 2024.11.28 |
| [React] xlsx-js-style (1) | 2024.11.26 |
| [React] Styled-Compoent (1) | 2024.11.15 |