-
Notifications
You must be signed in to change notification settings - Fork 487
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
feat(@clayui/date-picker): add props to control expand functionality #3264
Conversation
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.
LGTM!
Pull Request Test Coverage Report for Build 111789209
💛 - Coveralls |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 1ec1255:
|
const setExpanded = (val: boolean) => { | ||
if (expanded !== val && onExpandedChange) { | ||
onExpandedChange(val); | ||
} | ||
|
||
setInternalExpanded(val); | ||
}; | ||
|
||
React.useEffect(() => { | ||
if (expanded !== undefined) { | ||
setInternalExpanded(expanded); | ||
} | ||
}, [expanded]); |
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.
Perhaps we can decrease the use here of useEffect
which could happen a double rendering due to the useState
that the developer will have to use to control. I'm thinking of something like this:
const expanded = externalExpanded !== undefined ? externalExpanded : internalExpanded;
const setExpanded = onExpandedChange ? onExpandedChange : setInternalExpanded;
externalExpanded
can only be an alias of expanded
prop. What do you think? it's makes sense for you?
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.
@matuzalemsteles let me try that out. That was my goal but my first iteration was having issues. Let me look again to see if this is possible.
fixes #3262