-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Stack] Converted to a functional component #2534
Conversation
Given my talk in #2062 about our cargo-culty usage of PureComponent and how I'd like us to stop doing that I don't think we should bother wrapping this in a React.memo |
7815b30
to
eb08021
Compare
e619468
to
2f8cf08
Compare
For other readers, response to Ben here |
}); | ||
|
||
return <div className={className}>{itemMarkup}</div>; | ||
}) as NamedExoticComponent<StackProps> & { |
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.
In other cases where we need this recasting it's been done at the top of the constant declaration rather than using an as
, see Autocomplete for any example. Can we keep to that style for consistency?
export const Stack: React.NamedExoticComponent<StackProps> & {
Item: typeof Item;
} = function memo(function Stack({
//...
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.
Typing is always preferred overcasting, however, unfortunately, we can't in this situation.
Type 'NamedExoticComponent<StackProps>' is not assignable to type 'NamedExoticComponent<StackProps> & { Item: ({ children, fill }: ItemProps) => Element; }'.
Property 'Item' is missing in type 'NamedExoticComponent<StackProps>' but required in type '{ Item: ({ children, fill }: ItemProps) => Element; }'
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.
well that's a little annoying :(
/me waves fist at React.memo
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
WHY are these changes introduced?
More context here
This open in a tab, will polish and request reviews after hack days.