-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[FormControl] Convert to function component #15208
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
[FormControl] Convert to function component #15208
Conversation
joshwooding
commented
Apr 4, 2019
- I have followed (at least) the PR section of the contributing guide.
|
@material-ui/core: parsed: -0.14% 😍, gzip: -0.10% 😍 Details of bundle changes.Comparing: 496b0ff...148ea35
|
|
|
||
| const [focused, setFocused] = React.useState(false); | ||
|
|
||
| if (disabled && focused) { |
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.
Wow, at first I was like: wtf is this. But then, looking twice at the logic, it looks valid 👌.
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 is the function component version of
static getDerivedStateFromProps(props, state) {
if (props.disabled && state.focused) {
return { focused: false };
}
return null;
}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.
Thanks for the link.