cornerstonejs / react-cornerstone-viewport

Cornerstone medical image viewport component for React
https://react.cornerstonejs.org/
MIT License
96 stars 75 forks source link

[Issue] Usage of deprecated `findDOMNode` in dependency library #122

Closed burnpiro closed 2 years ago

burnpiro commented 2 years ago

Solution in #123

Expected Behavior

Library loads without warnings.

Actual Behavior

The library throws a warning:

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

Caused by ReactResizeDetector using findDOMNode when no reference element is provided. FindDOMNode is deprecated and there is a description in React's docs: https://reactjs.org/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage.

Possible solution

There is a solution mentioned in docs for version 6.7.6 of react-resize-detector, which uses targetRef to specify target reference and stop calling findDOMNode from react-dom.

https://www.npmjs.com/package/react-resize-detector#user-content-refs

This is not available in version used by react-cornerstone-viewport which uses "react-resize-detector": "^4.2.1" but reference in 4.2.1 documentation has similar solution that uses targetDomEl https://www.npmjs.com/package/react-resize-detector/v/4.2.1#api.

Steps to Reproduce the Problem

  1. Install react-cornerstone-viewport
  2. import CornerstoneViewport from 'react-cornerstone-viewport'
  3. add Viewport as component <CornerstoneViewport enableResizeDetector={true} />

Specifications

tugot17 commented 2 years ago

Same issue here

swederik commented 2 years ago

Closed in #123! Thanks!