Bug: Class component with defaultProps
not merging props correctly in componentDidMount
#28505
Labels
defaultProps
not merging props correctly in componentDidMount
#28505
React version:
18.2.0
Steps To Reproduce
lazy
-wrapped, class-component withdefaultProps
,componentDidMount
andcomponentWillUnmount
.StrictMode
, on initial call tocomponentDidMount
,this.props
containsdefaultProps
correctly.this.props
isn't merged withdefaultProps
correctly.Link to code example:
https://stackblitz.com/edit/vitejs-vite-1ptuah?file=src%2Fmain.jsx
The current behavior
The
StrictMode
-triggered 2nd mount doesn't correctly mergedefaultProps
intothis.props
.The expected behavior
this.props
contains the specifieddefaultProps
.More context
I noticed each of the following works-around the issue:
lazy
)lazy
componentWillUnmount
Since this is happening in a 3rd-party which we wrap with
lazy
, the 1st option is a solid workaround for now.Possibly related issues
The text was updated successfully, but these errors were encountered: