Remove handling on findDOMNode warning (#67054)

This commit is contained in:
Sebastian Silbermann 2024-06-21 14:17:02 +02:00 committed by GitHub
parent 98100135f0
commit 688eb77c0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -98,27 +98,13 @@ const __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = (
function findDOMNode(
instance: React.ReactInstance | null | undefined
): Element | Text | null {
// Tree-shake for server bundle
if (typeof window === 'undefined') return null
// __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode is null during module init.
// We need to lazily reference it.
const internal_reactDOMfindDOMNode =
__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode
// Tree-shake for server bundle
if (typeof window === 'undefined') return null
// Only apply strict mode warning when not in production
if (process.env.NODE_ENV !== 'production') {
const originalConsoleError = console.error
try {
console.error = (...messages) => {
// Ignore strict mode warning for the findDomNode call below
if (!messages[0].includes('Warning: %s is deprecated in StrictMode.')) {
originalConsoleError(...messages)
}
}
return internal_reactDOMfindDOMNode(instance)
} finally {
console.error = originalConsoleError!
}
}
return internal_reactDOMfindDOMNode(instance)
}