findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which 的解决

1. The emergence of the problem:

  1. During the reacttime of project development, the emergence of this error, findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which is inside StrictMode. Instead, add a ref directly to the element you want to reference.as follows:

Insert picture description here

2. Problem analysis and solution:

  1. Analysis of the problem: This error is described in StrictModethe not recommended findDOMNode, findDOMNodeis transferred to the StrictModeconverted instances within. Instead, add directly to the element to be referenced ref. This is actually opened up reacta strict mode, use the <React.StrictMode>tag.
  2. To solve the problem: Turn off strict mode in the index.jsfile, remove <React.StrictMode>the label warning will disappear, as follows:

Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_42614080/article/details/113662378