componentDidUpdate inexplicably not firing after render in a single component
See original GitHub issueDo you want to request a feature or report a bug?
Bug
What is the current behavior?
componentDidUpdate
not firing after render
in one lone component. No idea how to recreate in a sandbox.
What is the expected behavior?
componentDidUpdate
fires after every render
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React@16.11
& React@16.12
affected in Electron@6
I’m tracking when componentDidUpdate
and render
are firing with log statements.
The log statements in componentDidUpdate
do not fire after render
. I have used breakpoints to confirm this isn’t a timing issue.
My code (stripped down) is below. This is the output of the logging. Sometimes I’ll get componentDidUpdate
to fire, but inconsistently and it’s never the final thing, a RENDER
always shows up in my logs last, never UPDATE
.
class MyWrapper extends React.PureComponent {
render() {
const { buttonDefinitions } = this.props;
return (
<InfoProvider
render={infoProps => {
return (
<MyMenu
{...{ buttonDefinitions, infoProps }}
/>
);
}}
/>
);
}
}
class MyMenu extends React.Component {
componentDidUpdate() {
log.warn('UPDATE');
}
render() {
log.warn('RENDER');
const { buttonDefinitions } = this.props;
return (
<MenuWrapper>
{buttonDefinitions.map(buttonDef => (
<MyButton {...buttonDef} />
))}
</MenuWrapper>
);
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Not necessarily true, although if the DOM is being modified then the commit phase has run and it should definitely be called in that case.
I’d say this is a necessary next step in order for someone to actually look into the issue 🙂 It’s probably going to be easier for you to start stripping things out of your app than it would be for us to speculate about all of the things that could be inside an app we’ve never seen.
Ah, interesting! 😄 Thanks for the follow up. Glad you got it sorted out.