用react做的后台管理项目,更换路由之后出现了这个警告,有人遇到过吗?

新手上路,请多包涵

Warning: The <HeadTable /> component appears to be a function component that returns a class instance. Change HeadTable to a class that extends React.Component instead. If you can't use a class try assigning the prototype on the function as a workaround. HeadTable.prototype = React.Component.prototype. Don't use an arrow function since it cannot be called with new by React.

clipboard.png

阅读 7.6k
2 个回答

提示说的不要太清楚;你的代码写的不符合 react 的官方推荐,所以给你警告

我好想解决了,只有在开发环境下才有,发布后就没有这个问题了,如果要解决开发环境下的问题,应该是热更新时导致的。我们在resolve的alias里加入了'react-dom': '@hot-loader/react-dom'

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题