error after upgrading react-bootstrap - CustomModalDialog is out of date
See original GitHub issueAfter one of the latest versions update, with react-bootstrap
update, maybe #3249,
my environment is with the latest react and react-dom and my tests started to fail with the following error:
console.error node_modules/jest-prop-type-error/index.js:8
onMouseDownDialog
in div (created by CustomModalDialog)
in CustomModalDialog (created by Modal)
in Transition (created by Fade)
in Fade (created by DialogTransition)
in DialogTransition (created by Modal)
in RefHolder (created by Modal)
in div (created by Modal)
in Portal (created by Modal)
in Modal (created by Modal)
in Modal (created by DiffModal)
and the warning:
Warning: Unknown event handler property
%s. It will be ignored.%s
maybe it is something about a naming convention, see: https://github.com/styled-components/styled-components/issues/2218#issuecomment-489661463
opened an issue to react-bootstrap
- https://github.com/react-bootstrap/react-bootstrap/issues/4872
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:7 (2 by maintainers)
Top Results From Across the Web
React-Bootstrap modal not closing. Error: Cannot update a ...
What this does is: on each render of PersonalDetails , this will just set the state for the show state back in OnboardPage...
Read more >react-bootstrap's Modal does not work with React 16 #2812
When I upgraded to React 16, everything in my app worked as normal except for react-bootstrap Modals. I'm seeing the same context.contains error...
Read more >Working with Bootstrap's Modals in React | Pluralsight
In this guide I will show you how to install react-bootstrap, show and hide a modal, work with different modal events, and customize...
Read more ><Modal/> Component - React-Bootstrap
Modals are unmounted when closed. Bootstrap only supports one modal window at a time. Nested modals aren't supported, but if you really need...
Read more >Get started with Bootstrap · Bootstrap v5.2
Get started by including Bootstrap's production-ready CSS and JavaScript via CDN ... Stay up-to-date on the development of Bootstrap and reach out to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, I think I figured out what’s going on here. This is the version of the error I’m seeing in v2v:
It looks like the problem is that an
onMouseDownDialog
prop is being applied to a plain<div>
element, causing a warning since this is not a valid prop for a<div>
. I can only find one place in react-bootstrap@0.33.0 where this prop is passed, and it appears to be coming from this line: https://github.com/react-bootstrap/react-bootstrap/blob/bs3-dev/src/Modal.js#L287That
<Dialog>
the prop is being passed to there is actually defined by thedialogComponentClass
prop here, which defaults toModalDialog
here. If passed toModalDialog
as is the default behavior, it’s handled correctly and won’t be applied to a<div>
.So this means that somewhere, a
<Modal>
is being rendered withdialogComponentClass
set to either a div or something that passes all its props to a div. I can’t find anywhere in the react-bootstrap code where that is happening, so I started thinking it might be our usage in patternfly-react.Searching patternfly-react for
dialogComponentClass
reveals that we pass our ownCustomModalDialog
into this prop in our wrapper for react-bootstrap’s Modal: https://github.com/patternfly/patternfly-react/blob/master/packages/patternfly-3/patternfly-react/src/components/Modal/Modal.js#L23. It turns out, we made a copy of the original r-bsModalDialog
as our own CustomModalDialog with some tweaks.So, the bug is happening because
CustomModalDialog
ends up including the unexpectedonMouseDownDialog
prop in itselementProps
object, which it then spreads directly onto the<div>
here.To fix this, we simply need to update our
CustomModalDialog
to replicate this change react-bootstrap made to their original ModalDialog: https://github.com/react-bootstrap/react-bootstrap/commit/87a9a97f8670f3a02436f8f520caf36f88e4bdab#diff-e62f630dfbeeba1084a3724f9d4dbf98 and pull theonMouseDownDialog
prop out and apply it to the div asonMouseDown
.While we’re at it, we should probably just update that whole file to match the new react-bootstrap version in case anything else changed, and preserve whatever it was that we modified to be custom. Maybe we can even just stop using that custom component. We should look for others like it that we copy-pasted… we may have caused other issues by essentially upgrading react-bootstrap while overriding bits of it with its old code.
Hi @laviro our team has seen this, and we will be taking a look at it this week.