chore: warning for rsc (#45992)

* chore: warning for rsc

* chore: code clean
pull/46000/head
MadCcc 1 year ago committed by GitHub
parent 37f6d43f17
commit b533996d2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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';

@ -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';

Loading…
Cancel
Save