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

Fix case where checked bundles in sidebar don't update #317

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/components/CheckboxList.jsx
Expand Up @@ -33,6 +33,8 @@ export default class CheckboxList extends PureComponent {
this.setState({checkedItems});
this.informAboutChange(checkedItems);
}
} else if (newProps.checkedItems !== this.props.checkedItems) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I lean towards this being a good short-term fix, this method is now getting difficult to reason about IMO (in way that lines up with some of the arguments made here). A few possibilities to simplify a bit, going from slight change to more radical change:

  1. Switch from componentWillReceiveProps (deprecated) to getDerivedStateFromProps. Would make intent clearer IMO, but might not be able to fully replace the this.informAboutChange part.
  2. Centralize the "all checked" logic in MobX store
  3. Use Hooks (could clean up a lot but biggest change / introduces new paradigm to the app)

(I like idea of trying option 2 personally)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let @th0r weigh in on the refactoring opportunity ☺️

For now, as this change fixes the bug, let's ship this and consider the refactor in its own PR as it makes it easier to review a refactor when it keeps the existing functionality 1:1 to what was before.

this.setState({checkedItems: newProps.checkedItems});
}
}

Expand Down