Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed application lifecycle bunq/doc#75 #78

Merged
merged 1 commit into from
Nov 6, 2018

Conversation

parrello
Copy link

@parrello parrello commented Nov 5, 2018

No description provided.

@@ -67,7 +67,7 @@ class SidebarItem extends React.Component {

/**
*/
componentDidMount () {
componentDidUpdate () {
if (!this.state.isApiEndpoint) {

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 do if (prevState.isApiEndpoint && !this.state.isApiEndpoint) {

Copy link
Author

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?

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 :)

@kojoru kojoru merged commit c451b03 into develop Nov 6, 2018
@kojoru kojoru deleted the bunq/doc#75_change_lifecycle branch November 6, 2018 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants