salesforce / design-system-react

Salesforce Lightning Design System for React
https://design-system-react-site.herokuapp.com/
BSD 3-Clause "New" or "Revised" License
913 stars 415 forks source link

replace usage of findDOMNode with creating selfRef in constructor #3054

Closed DNiederweis closed 2 years ago

DNiederweis commented 2 years ago

Fixes # Deprecation warning in console for findDOMNode in StrictMode.

Additional description

findDOMNode is deprecated in StrictMode as it "breaks abstraction levels" and "creates a refactoring hazard" - React Documentation. The React documentation instead encourages the use of references.

This pull request follows this advice and creates a self-reference in the constructor(selfRef). This reference is then used in componentDidUpdate when it is checked whether the modal is closing. If it is, then instead of using findDOMNode to get a reference to the modal and using that for unmounting and removing from the DOM, it instead uses the selfRef now.


CONTRIBUTOR checklist (do not remove)

Please complete for every pull request

REVIEWER checklist (do not remove)

interactivellama commented 2 years ago

Thanks. This is legacy code that should be not be used, but is still here for backwards support.

welcome[bot] commented 2 years ago

Congrats on merging your first pull request to Design System React! :tada: If you have a moment, please fill out this five question survey, we would appreciate it. On behalf of Salesforce's customers, partners, product specialists and employees, we would like offer sincere thanks and appreciation for helping make our user experience better. We look forward to working with you more in the future. This definitely calls for a high five! Alt High Five