Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case of
componentDidUpdate
you want to make a comparison to the previous state. this method runs on every update on anything on state / props, and whenever!this.state.isApiEndpoint
holds that code block will be called causing unnecessary rerenders - not sure whether this one would cause an infinite rerender or sth but I would check the behaviour with some logs.the function signature is
componentDidUpdate(prevProps, prevState)
, this should work nicely if you doif (prevState.isApiEndpoint && !this.state.isApiEndpoint) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@melikesofta the state of the component is never updated, so there's no risk of generating an infinite loop. The reason why I want to go this way is that right now I cannot know exactly when the markdown generating the documentation has been displayed, so I want to check this every time I render. Am I missing anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the result of
this.props.bunqSelectors.initializeScrollToTopic(this.state.tag);
doesn't affect this component i.e. props sent from the parent will remain the same it should be fine, otherwise it will infinitely trigger a rerender by itself. there might be some props sent down that might not be obvious but still trigger a rerender, but if you already checked or if you are sure it's fine :)