Reputation: 1056
I have a third party component that I need to completely re-render when the props I pass to it change.
How do I get it to re-render completely without getting the vendor to update their code? (Seems to be a shortcoming in their code)
I've tried this.forceUpdate()
and it doesn't fully re-render their component.
Upvotes: 2
Views: 3607
Reputation: 1056
Use the props you want to monitor as the key
of the component you're trying to re-render.
e.g. <ThirdPartyComponent key={this.props.foo} ...>
--
If you need to monitor more then one prop, consider combining them in a way that represents their purpose (and if one changes, they both change). The below assumes they're both strings.
e.g. <ThirdPartyComponent key={`${this.props.foo}/${this.props.bar}`} ...>
Upvotes: 7