Skip to content

Commit

Permalink
chore: warning for rsc (ant-design#45992)
Browse files Browse the repository at this point in the history
* chore: warning for rsc

* chore: code clean
  • Loading branch information
MadCcc authored Nov 21, 2023
1 parent 37f6d43 commit b533996
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/date-picker/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ The default locale is en-US, if you need to use other languages, recommend to us

If there are special needs (only modifying single component language), Please use the property: local. Example: [default](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json).

<!-- prettier-ignore -->
:::warning
When use with Nextjs App Router, make sure to add `'use client'` before import locale file of dayjs.
It's because all components of Ant Design only works in client, importing locale in RSC will not work.
:::

```jsx
import locale from 'antd/es/date-picker/locale/zh_CN';

Expand Down
6 changes: 6 additions & 0 deletions components/date-picker/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ demo:

如有特殊需求(仅修改单一组件的语言),请使用 locale 参数,参考:[默认配置](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json)

<!-- prettier-ignore -->
:::warning
在搭配 Nextjs 的 App Router 使用时,注意在引入 dayjs 的 locale 文件时加上 `'use client'`
这是由于 Ant Design 的组件都是客户端组件,在 RSC 中引入 dayjs 的 locale 文件将不会在客户端生效。
:::

```jsx
import locale from 'antd/es/date-picker/locale/zh_CN';

Expand Down

0 comments on commit b533996

Please sign in to comment.