-
Notifications
You must be signed in to change notification settings - Fork 161
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
Tree component refactoring #1863
Conversation
Using ReturnType on all sub-states except for controls (which already has a type to be used directly) and narrative (the compiler was not able to resolve types between return values and default state). The next commit will fix the narrative type.
9ecca22
to
8280aaa
Compare
8280aaa
to
33277b5
Compare
src/components/tree/tree.js
Outdated
} | ||
|
||
clearSelectedNode = () => { | ||
callbacks.clearSelectedNode.bind(this); |
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.
[reminder to me] - check this change, I remember binding callbacks in the constructor was "the right way" way back when I was writing this code.
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.
I see:
auspice/src/components/map/map.js
Lines 84 to 85 in 3cd0c1e
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md#es6-classes | |
this.fitMapBoundsToData = this.fitMapBoundsToData.bind(this); |
@genehack could you take a look at the types added / used here if you have a chance? 🙏 |
This was necessary to properly type the root state. Note: AnyAction is used for `action` which is only slightly better than any. Ideally, each action type would come with its own TypeScript interface but there is no good way to tightly couple those. I think the right improvement here is to use Redux's createSlice but that is beyond the scope of adding types.
This allows type checking on the new entries.
This does not provide much benefit as-is, but should facilitate future usage of TypeScript within the component.
The commented out usage was removed in "Excise react-svg-pan-zoom" (56fbb8a).
Keep consistent with other parts of the file.
Only the clearSelectedNode binding needs to be kept in the constructor.
6d65167
to
ceec881
Compare
- `treeIsZoomed` is ambiguous since the condition considers two trees. Rename to `anyTreeZoomed`. - `activeResetTreeButton` has the same condition as `anyTreeZoomed`. Reuse the existing variable.
Partial<ControlsState> previously worked but has the side effect of marking all keys as optional, which is not accurate and prone to cause future type errors.
ceec881
to
4658803
Compare
Description of proposed changes
Changes made while prepping for #1373. These can be considered independently from that PR. See individual commit messages.
Checklist
If making user-facing changes, add a message in CHANGELOG.md summarizing the changes in this PRno functional changes(to be done by a Nextstrain team member) Create preview PRs on downstream repositories.no functional changes