0

I have react application with ant design . Any time i chage "locale" prop from/to EN it will unmount all children components:

import { ConfigProvider } from 'antd';
import enUS from "antd/lib/locale/en_US";
import zhCN from "antd/lib/locale/sk_SK";

<ConfigProvider locale="this.state.locale">
   <AnyChild key="even with const key will unmount" />
</ConfigProvider>

here are 2 same sandbox. only change is locale. First is using EN, second do not

sandbox WITH english language

sandbox WITH NO english language

You can see in console log that the one with english locales will unmount child component. Does anyone know why is it, and how can make Provider with EN locale that won't unmount components?

martin clayton
  • 76,436
  • 32
  • 213
  • 198
Juraj Kocan
  • 2,648
  • 1
  • 15
  • 23
  • I may be wrong, so im not posting this as answer, i think in the second examples the 2 locales are really similar (some words are identical) so react diffing algorithm do not detect changes and will not update state. – Nico Apr 13 '21 at 14:15
  • probably if you could run componentWillUnmount inside components that changes, such as labels, you will still have the message – Nico Apr 13 '21 at 14:21

0 Answers0