Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: findDOMNode is deprecated in StrictMode. #5075

Closed
freemaths opened this issue Mar 27, 2020 · 27 comments · Fixed by #5687
Closed

Warning: findDOMNode is deprecated in StrictMode. #5075

freemaths opened this issue Mar 27, 2020 · 27 comments · Fixed by #5687

Comments

@freemaths
Copy link

Error generated when using
Warning: findDOMNode is deprecated in StrictMode.

Tested with latest 1.0.0 release of recat-bootstrap

From what I can see this is a known issue with react-bootstrap but I am not clear on when it will be fixed or any workarounds in the meantime. Console errors are not helpful when developing. Turning off strict mode compromises other development.

see: https://reactjs.org/docs/strict-mode.html

@mxschmitt
Copy link
Member

function wrapRefs(props, arrowProps) {
const { ref } = props;
const { ref: aRef } = arrowProps;
props.ref = ref.__wrapped || (ref.__wrapped = (r) => ref(findDOMNode(r)));
arrowProps.ref =
aRef.__wrapped || (aRef.__wrapped = (r) => aRef(findDOMNode(r)));
}

const getTarget = useCallback(
() => ReactDOM.findDOMNode(triggerNodeRef.current),
[],
);

seems like at these two places, hmmm. We already had this issue come up a few month ago if I remember correctly.

@freemaths
Copy link
Author

freemaths commented Mar 27, 2020

Yes, many thanks. I found some references earlier but all were closed and I couldn't see any clear instructions on work-arounds or when it might be fixed. I think it applies to some other components too.

@jquense
Copy link
Member

jquense commented Mar 27, 2020

arg, we should have removed this probably, like we did for dropdowns.

What we can do tho is only call findDOMNode if required. that way users can avoid it themselves by not using class component refs

@freemaths
Copy link
Author

Thanks. Happy to test any updated version.

@avxkim
Copy link

avxkim commented Mar 30, 2020

Just faced the same issue on a clean CRA app with react-bootstrap@1.0.0

@jquense
Copy link
Member

jquense commented Mar 30, 2020

PR's welcome if folks wanna get it fixed quicker, we will get to it but it's lower on the priority list since it's an opt in warning

@Korywon
Copy link

Korywon commented Apr 1, 2020

I encountered this warning as well when using the navbar collapse. Here's the stacktrace:

    in div (created by Context.Consumer)
    in Transition (created by Collapse)
    in Collapse (created by Context.Consumer)
    in NavbarCollapse (at navbar-menu.component.js:18)
    in nav (created by Navbar)
    in Navbar (at navbar-menu.component.js:13)
    in NavbarMenu (at App.js:18)
    in Router (created by BrowserRouter)
    in BrowserRouter (at App.js:17)
    in App (at src/index.js:9)
    in StrictMode (at src/index.js:8)

Haven't found the reference in code just yet.

@ratchapol-an
Copy link

Modal also has this issue too.

index.js:1 Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Modal which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://fb.me/react-strict-mode-find-node
in div (created by Modal)
in Transition (created by Fade)
in Fade (created by BackdropTransition)
in BackdropTransition (created by Modal)
in Modal (created by ForwardRef)
in ForwardRef (created by Modal)
in Modal (created by Bootstrap(Modal))
in Bootstrap(Modal) (at NewCustomerModal.tsx:13)
in NewCustomerModal (at Customers.tsx:27)
in div (at Customers.tsx:18)
in Customers (at withMainLayout.tsx:26)
in div (created by Container)
in Container (at withMainLayout.tsx:25)
in main (at withMainLayout.tsx:23)
in div (at withMainLayout.tsx:21)
in withMainLayout(Component) (created by Context.Consumer)
in Route (at Routes.tsx:11)
in Switch (at Routes.tsx:9)
in Router (created by BrowserRouter)
in BrowserRouter (at Routes.tsx:8)
in Routes (at App.tsx:7)
in App (at src/index.tsx:11)
in StrictMode (at src/index.tsx:10)

@HunteRoi
Copy link

HunteRoi commented Apr 4, 2020

Just got the issue with Accordion.Collapse :

index.js:1 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. Learn more about using refs safely here: https://fb.me/react-strict-mode-find-node
    in div (created by AccordionCollapse)
    in Transition (created by Collapse)
    in Collapse (created by AccordionCollapse)
    in AccordionCollapse (at Contributor/index.tsx:30)
    in div (created by ForwardRef)
    in ForwardRef (at Contributor/index.tsx:26)
    in div (at Contributor/index.tsx:25)
    in Contributor (at App/index.tsx:33)
    in div (at PageLayout/index.tsx:18)
    in main (at PageLayout/index.tsx:17)
    in div (at PageLayout/index.tsx:12)
    in PageLayout (at App/index.tsx:32)
    in Route (at App/index.tsx:31)
    in Switch (at App/index.tsx:14)
    in Router (created by BrowserRouter)
    in BrowserRouter (at App/index.tsx:13)
    in App (at src/index.tsx:10)
    in StrictMode (at src/index.tsx:9)

@kheide
Copy link

kheide commented Apr 7, 2020

Tab.Pane also has the same issue

@HunteRoi
Copy link

HunteRoi commented Apr 7, 2020

I have quickly checked the repository to find all findDOMNode references and here are the places where it is currently used and/or referenced as documentation :

I unfortunately don't have the required knowledge of the library to make the changes myself and create a pull request. I hope that somebody will be able to fix it.

@jquense
Copy link
Member

jquense commented Apr 8, 2020

I'm in the process of fixing this upstream with: https://github.com/react-bootstrap/react-overlays/pull/794/files#diff-97a43659c6311e819ce665f4a3291f58 which we can use here as well once it's merged and upgraded

@ajayala
Copy link

ajayala commented Apr 19, 2020

Some of the issues came from a dependency, react-transition-group. It has to be fixed from this side. Here's the offending code:

https://github.com/reactjs/react-transition-group/blob/master/src/Transition.js

If you don't need the transition, as a temporary fix, you can set transition attribute to false.

<Tabs transition={false} > ... </Tabs>

@HunteRoi
Copy link

It looks like they already know about the issue in this particular library as well : #429

@martinKindall
Copy link

martinKindall commented Apr 19, 2020

Had this issue using <Modal ../>

index.js:1 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. Learn more about using refs safely here: https://fb.me/react-strict-mode-find-node
in div (created by Modal)
in Transition (created by Fade)
in Fade (created by BackdropTransition)
in BackdropTransition (created by Modal)
in Modal (created by ForwardRef)
in ForwardRef (created by Modal)
in Modal (created by Bootstrap(Modal))
in Bootstrap(Modal) (at FilterForm.tsx:13)
in FilterForm (at Searcher.tsx:29)
in Searcher (at BottomBar.tsx:80)
in Route (at BottomBar.tsx:79)
in Switch (at BottomBar.tsx:68)
in div (at BottomBar.tsx:26)
in BottomBar (at App.tsx:9)
in Router (created by BrowserRouter)
in BrowserRouter (at App.tsx:8)
in App (at src/index.tsx:9)
in StrictMode (at src/index.tsx:8)

"bootstrap": "^4.4.1",
"react": "^16.13.1",
"react-bootstrap": "^1.0.0",

@devcrp
Copy link

devcrp commented Apr 23, 2020

Thanks @jquense ! Upgrading to the fresh 1.0.1 version fixed it for Modals, although it only works if animated is set to false.

@jquense
Copy link
Member

jquense commented Apr 23, 2020

Yes we are waiting for react transition group to update as well

@mabsystems
Copy link

mabsystems commented Apr 24, 2020

v.1.0.1: "Warning: findDOMNode is deprecated" still actual for Modal

@envious
Copy link

envious commented Apr 24, 2020

Also facing this issue.

@sylwiasuwalska
Copy link

Modal with animation set to false.
Updated to v 1.0.1.

index.js:1 Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Modal which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://fb.me/react-strict-mode-find-node
in div (created by Modal)
in Modal (created by ForwardRef)
in ForwardRef (created by Modal)
in Modal (created by Bootstrap(Modal))
in Bootstrap(Modal) (at Options.js:25)
in Options (at Grid.js:152)
in div (created by Col)
in Col (at Grid.js:151)
in div (created by Row)
in Row (at Grid.js:146)
in Grid (at App.js:24)
in div (created by Container)
in Container (at App.js:8)
in App (at src/index.js:10)
in StrictMode (at src/index.js:9)

@carliey
Copy link

carliey commented May 2, 2020

Having the same issue with material-ui dialog

@devcrp
Copy link

devcrp commented May 4, 2020

I must be doing something different, because creating the modal with animation={false} doesn't raise the warning for me, and I got it if I set it to true.

<Modal
show={showMultiple}
onHide={() => setShowMultiple(false)}
animation={false}
>
<Modal.Header closeButton>
<Modal.Title>Modal heading</Modal.Title>
</Modal.Header>
<Modal.Body>Woohoo, you're reading this text in a modal!</Modal.Body>
<Modal.Footer>
Select
</Modal.Footer>

@garycyyeung
Copy link

garycyyeung commented May 5, 2020

I had the same messages before when I used Modal or Alert

The following is the solution for fixing the issue:

  1. For Modal, add animation={false} within the tag
  2. For Alert, add transition={null} within the tag

@wolfgang-reutz
Copy link

I have the error with Accordion when I toggle a Accordion.Collapse element.
Tried both animation and transition parameter with false and null but no luck.

Any hints on how to fix this problem for Accordion until react-transition fixes it?

using react-bootstrap@1.0.1

@kunuit
Copy link

kunuit commented May 15, 2020

So sad, my eyes don't like it

```

index.js:1 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. Learn more about using refs safely here: https://fb.me/react-strict-mode-find-node
in div (created by ForwardRef(Paper))
in ForwardRef(Paper) (created by WithStyles(ForwardRef(Paper)))
in WithStyles(ForwardRef(Paper)) (created by Transition)
in Transition (created by ForwardRef(Grow))
in ForwardRef(Grow) (created by TrapFocus)
in TrapFocus (created by ForwardRef(Modal))
in div (created by ForwardRef(Modal))
in ForwardRef(Portal) (created by ForwardRef(Modal))
in ForwardRef(Modal) (created by ForwardRef(Popover))
in ForwardRef(Popover) (created by WithStyles(ForwardRef(Popover)))
in WithStyles(ForwardRef(Popover)) (created by ForwardRef(Menu))
in ForwardRef(Menu) (created by WithStyles(ForwardRef(Menu)))
in WithStyles(ForwardRef(Menu)) (at Header/index.js:42)
in div (at Header/index.js:59)
in Header (created by WithStyles(Header))
in WithStyles(Header) (at Dashboard/index.js:13)
in div (at Dashboard/index.js:12)
in Dashboard (created by WithStyles(Dashboard))
in WithStyles(Dashboard) (at AdminLayoutRoute/index.js:18)
in Route (at AdminLayoutRoute/index.js:14)
in AdminLayoutRote (created by WithStyles(AdminLayoutRote))
in WithStyles(AdminLayoutRote) (at App/index.js:27)
in Switch (at App/index.js:49)
in ThemeProvider (at App/index.js:44)
in Router (created by BrowserRouter)
in BrowserRouter (at App/index.js:43)
in Provider (at App/index.js:42)
in App (created by WithStyles(App))
in WithStyles(App) (at src/index.js:9)
in StrictMode (at src/index.js:8)
console. @ index.js:1
r @ react_devtools_backend.js:6
printWarning @ react-dom.development.js:88
error @ react-dom.development.js:60
findHostInstanceWithWarning @ react-dom.development.js:24306
findDOMNode @ react-dom.development.js:24804
performEnter @ Transition.js:245
updateStatus @ Transition.js:228
componentDidUpdate @ Transition.js:192
commitLifeCycles @ react-dom.development.js:19835
commitLayoutEffects @ react-dom.development.js:22803
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
commitRootImpl @ react-dom.development.js:22541
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
commitRoot @ react-dom.development.js:22381
finishSyncRender @ react-dom.development.js:21807
performSyncWorkOnRoot @ react-dom.development.js:21793
(anonymous) @ react-dom.development.js:11089
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushSyncCallbackQueueImpl @ react-dom.development.js:11084
flushSyncCallbackQueue @ react-dom.development.js:11072
discreteUpdates$1 @ react-dom.development.js:21893
discreteUpdates @ react-dom.development.js:806
dispatchDiscreteEvent @ react-dom.development.js:4168

@jquense
Copy link
Member

jquense commented May 15, 2020

Folks please stop posting the same example of react-transition-group causing an error, its not helpful to the discussion. We know why these occur, If someone wants to upgrade RTG to the latest and migrate to the nodeRef API that will speed this along, otherwise don't run in StrictMode if you don't want to see the errors thanks!

@react-bootstrap react-bootstrap locked and limited conversation to collaborators May 15, 2020
@kyletsang kyletsang linked a pull request Mar 3, 2021 that will close this issue
@kyletsang
Copy link
Member

Fixed in v2 alpha

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.