-
Notifications
You must be signed in to change notification settings - Fork 0
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
Exchange defaultProps for default parameters in function components #1226
base: main
Are you sure you want to change the base?
Conversation
Started looking into removing |
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.
This looks really good! See my comments about CheckboxTree, and let me know what you think.
shouldCloseOnSelection, | ||
wrapPopover, | ||
currentList, | ||
selectedList = [], |
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 don't think we need this. Isn't selectedList
an option prop for CheckboxTree?
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.
It is but we use selectedList
below to auto close the popover.
setKey(selectedList.join(', '));
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.
(line 45 ish)
packages/libs/coreui/src/components/inputs/checkboxes/CheckboxTree/CheckboxTree.tsx
Outdated
Show resolved
Hide resolved
packages/libs/coreui/src/components/inputs/checkboxes/CheckboxTree/CheckboxTree.tsx
Outdated
Show resolved
Hide resolved
packages/libs/coreui/src/components/inputs/checkboxes/CheckboxTree/CheckboxTree.tsx
Outdated
Show resolved
Hide resolved
packages/libs/coreui/src/components/inputs/checkboxes/CheckboxTree/CheckboxTree.tsx
Outdated
Show resolved
Hide resolved
packages/libs/coreui/src/components/inputs/checkboxes/CheckboxTree/CheckboxTree.tsx
Outdated
Show resolved
Hide resolved
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.
It occurred to me that you could do something like this in the component:
function CheckboxTree<T>(partialProps: Props<T>) {
const props = { ...defaultProps, ...partialProps };
// ...
}
If a prop is defined in partialProps
, it's value will be used; otherwise, the value in defaultProps
will be used.
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.
This would be so much nicer. I tried this for a bit but could not shake a missing in types validation default props
error. Even after ensuring props
was of the correct type.
Happy to try something else if you have an idea of how to get around this!
Co-authored-by: Dave Falke <dfalke@uga.edu>
@dmfalke I finally got around to responding to comments! I also couldn't find a way around a type issue. But otherwise was mostly able to apply your suggestions! |
Testing now, and will re-request a review when tests are complete |
Looking good now. Ready for another look when you have a min, @dmfalke ! |
Partially resolves #1218
defaultProps
is being deprecated for function components. This PR removes the olddefaultProps
from all function components.Below is the list that Bob provided (for completeness). I either completed the update or found it was not a case that needed changing:
I also found
deafultProps
inCompound.jsx
,Gbrowse.jsx
, andOverviewThumbnail.jsx
but they were all being used with class components.Notes
SelectTree
, I removed the default props entirely if they both were the same as the component they were being passed to and caused no errors when removing.CheckboxTree.tsx
relied on default values being set, so i defined them in the file and then reused these values across the different functions.Sequence
component on gene record pages. Where does it get loaded? Otherwise I checked all the other updated components on the genomics or mbio site.