[有猿友说ta在类组件中不能使用,我在新的地方复现的时候发现确实;之前的实现无疑中绕过了useIntl,只是表面上实现了可以在类组件中使用;因此产生本次更新,将国际化完全困在一个函数组件中,这样就真的不管外面怎么调用了,因为之前进行了封装 ,因此本次修改 不会影响之前代码的编写--》更新IntlInit在在其中调用一个函数组件完成国际化功能】
使用umi中useIntl在类组件中时报错。
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
- You might have mismatching versions of React and the renderer (such as React DOM)
- You might be breaking the Rules of Hooks
- You might have more than one copy of React in the same app
相关问题描述
- 在非函数式组件中使用formatMessage 报错
- 无法在类组件中使用useIntl
- umi国际化不能在类组件中使用