react-bootstrap: OverlayTrigger - findDOMNode is deprecated in StrictMode

Hi

I am using Tooltip overlay from react-bootstrap but getting error findDOMNode is deprecated in StrictMode. As per documentation using the function form of overlaytrigger avoids a React.findDOMNode call, for those trying to be strict mode compliant but I am still getting the error as below.

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 Tooltip)
    in Tooltip (at NavMenu.tsx:31)
    in Transition (created by Fade)
    in Fade (created by Overlay)
    in Overlay (created by Overlay)
    in Overlay (created by OverlayTrigger)
    in OverlayTrigger (at NavMenu.tsx:28)
    in div (created by ForwardRef)
    in ForwardRef (created by Nav)
    in Nav (at NavMenu.tsx:27)
    in div (created by Context.Consumer)
    in Transition (created by ForwardRef)
    in ForwardRef (created by Context.Consumer)
    in NavbarCollapse (at NavMenu.tsx:23)
    in nav (created by Navbar)
    in Navbar (at NavMenu.tsx:18)
    in StrictMode (at src/index.tsx:13)

Code for OverLayTrigger

<OverLayTrigger 
     key="left" 
     placement="left" 
     overlay={<Tooltip id="tooltip-initials">{`Logged in as ${this.context.user?.name}`}</Tooltip>}>

{
    ({ref, ...triggerHandler}) => (
        <div className="avatar-circle" {...triggerHandler} >
            <span className="initials" id="initials" ref={ref}>
                {`${this.context.user?.given_name.substring(0,1)}${this.context.user?.family_name.substring(0,1)}`}
            </span>
        </div>
    )
}
</OverLayTrigger>

Can you please advise what I am missing above ?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 16
  • Comments: 16 (11 by maintainers)

Most upvoted comments

@kyletsang I added transition={false} which solved the findDOMNode error from react-transition-group each time the popover is displayed, but I still get an error when the popup is initially created and that one is coming from react-overlays@4.1.1 - is react-overlays supposed to be free of findDOMNode now? This issue is almost an year old, is there something blocking it? I can try to look into it.

@kyletsang Ok, I will try to come up with something

I tried passing a child function, but I still get the warning

Oh sorry, the actual line should be transition={false}. And on that note, I just tried it on my side briefly and the overlay isn’t showing. I’ll look into this when I get a moment and update you later.

Duplicate of #5075