J Seabolt
J Seabolt

Reputation: 2998

React component updating/rendering - componentDidUpdate NOT called

I have a react component which is connected to a parent container. The container has mapStateToProps. I have a console log in the container. The props are updating. I can SEE the prop updating in the component/child.

componentDidUpdate is not being called. I have no idea how a render could possibly be called without componentDidUpdate being called. But that is happening. I see the component update on my screen, I have the props console.logged and they are updating. But componentDidUpdate is not. I feel like I'm crazy.

Has anyone experienced this before??

Upvotes: 1

Views: 366

Answers (1)

Ben Wheeler
Ben Wheeler

Reputation: 7384

I'm running into something similar now. Wondering if my component is unmounting/remounting, which would cause render without calling componentDidUpdate, right?

UPDATE: Yep, my component was unmounting/remounting because a parent component was responding to the change in redux state by no longer rendering my component. Can't call componentDidUpdate if I don't exist, and won't call componentDidUpdate if I'm mounting!

Upvotes: 1

Related Questions