React / Reactstrap 警告:在严格模式树中检测到旧上下文 API

Nel*_*les 12 strict reactjs reactstrap

这是全新的安装 - 我没有对警报组件进行任何转换

复制代码很简单

import React from "react";
import { Alert } from "reactstrap";

export const Index = () => {
   return (
      <div>
         <Alert color='primary'>This is a primary alert — check it out!</Alert>
      </div>
   );
};

Run Code Online (Sandbox Code Playgroud)

错误消息:请更新以下组件:过渡

在此处输入图片说明

如何一起更新Transition或消除它?

Sha*_*nks 24

我有同样的警告,我修复了它在index.js文件中更改的值<React.StrictMode>to <React.Fragment>。由于这消除了警告,因此不能保证您可以防弹。

  • 这不是“解决它”!沉默!=静音 (9认同)
  • 否决,因为这个答案会助长不良做法。 (3认同)

Nel*_*les 23

如果有人在搜索问题后来到这里并正在寻找洞察力,就是这样。

React Strap(在撰写本文时)使用react-transition-group事物淡入淡出和菜单上下滑动。在此处和 Github 上合并有关此主题的信息后,他们目前正在更新库。我通过忽略警告完成了该组件的编码。

它并没有阻碍该组件的迭代。快乐编码。