Skip to content
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

Merged
merged 2 commits into from
Jan 8, 2020
Merged

Conversation

AndrewMusgrave
Copy link
Member

WHY are these changes introduced?

More context here

This open in a tab, will polish and request reviews after hack days.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2019

💦 Potential splash zone of changes introduced to src/**/*.tsx in this pull request:

Files modified3
Files potentially affected28

Details

All files potentially affected (total: 28)
📄 UNRELEASED.md (total: 0)

Files potentially affected (total: 0)

🧩 src/components/Stack/Stack.tsx (total: 28)

Files potentially affected (total: 28)

📄 tests/build.test.js (total: 0)

Files potentially affected (total: 0)


This comment automatically updates as changes are made to this pull request.
Feedback, troubleshooting: open an issue or reach out on Slack in #polaris-tooling.

@BPScott
Copy link
Member

BPScott commented Dec 17, 2019

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

@AndrewMusgrave
Copy link
Member Author

For other readers, response to Ben here

@AndrewMusgrave AndrewMusgrave marked this pull request as ready for review January 6, 2020 22:36
});

return <div className={className}>{itemMarkup}</div>;
}) as NamedExoticComponent<StackProps> & {
Copy link
Member

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({
//...

Copy link
Member Author

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; }'

Copy link
Member

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

src/components/Stack/Stack.tsx Show resolved Hide resolved
Copy link
Contributor

@LauraAubin LauraAubin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AndrewMusgrave AndrewMusgrave merged commit c7b2435 into master Jan 8, 2020
@AndrewMusgrave AndrewMusgrave deleted the funcify-stack branch January 8, 2020 18:16
@LauraAubin LauraAubin temporarily deployed to production January 16, 2020 16:22 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants