-
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?
searchTerm, | ||
selectedList, | ||
searchTerm = '', | ||
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.
This will create a new array on each render. Use defaultCheckboxTreeProps.selectedList
to prevent that
selectedList = [], | |
selectedList = defaultCheckboxTreeProps.selectedList, |
onSelectionChange = () => { | ||
// | ||
}, |
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.
onSelectionChange = () => { | |
// | |
}, | |
onSelectionChange = defaultCheckboxTreeProps.onSelectionChange, |
onSearchTermChange = () => { | ||
// | ||
}, |
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.
onSearchTermChange = () => { | |
// | |
}, | |
onSearchTermChange = defaultCheckboxTreeProps.onSearchTermChange, |
searchIconName, | ||
searchIconPosition, | ||
searchBoxHelp, | ||
searchBoxHelp = '', | ||
searchPredicate = () => true, |
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.
searchPredicate = () => true, | |
searchPredicate = defaultCheckboxTreeProps.searchPredicate, |
additionalFilters, | ||
wrapTreeSection, | ||
shouldExpandOnClick = true, | ||
customCheckboxes, | ||
customCheckboxes = {}, |
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.
customCheckboxes = {}, | |
customCheckboxes = defaultCheckboxTreeProps.customCheckboxes, |
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.
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.