簡體   English   中英

使用React 16.3.2時未調用UNSAFE_componentWillReceiveProps

[英]UNSAFE_componentWillReceiveProps not called when using React 16.3.2

我遵循了https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path中的建議,升級到React 16.3.2后,我想重命名所有即將被淘汰的生命周期方法轉換為等效的UNSAFE_

但是我注意到UNSAFE_componentWillReceiveProps沒有調用UNSAFE_componentWillReceiveProps 當我將其更改回componentWillReceiveProps它可以工作。 有什么想法嗎?

class Chart extends React.Component<ChartProps> {
  chartContainer: SVGSVGElement;
  tooltip: HTMLDivElement;
  xScale: ScaleBand<string>;
  yScale: ScaleLinear<number, number>;

  UNSAFE_componentWillReceiveProps(nextProps: Props) {
    ...
  }
...
}

我發現了問題。 react-dom軟件包也需要升級到16.3.2版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM