aws-amplify / amplify-ui

Amplify UI is a collection of accessible, themeable, performant React (and more!) components that can connect directly to the cloud.
https://ui.docs.amplify.aws
Apache License 2.0
884 stars 280 forks source link

Fix Types For Tab Children #3256

Closed bestickley closed 1 year ago

bestickley commented 1 year ago

Before creating a new issue, please confirm:

On which framework/platform are you having an issue?

React

Which UI component?

Primitive components

How is your app built?

Vite

What browsers are you seeing the problem on?

Chrome

Please describe your bug.

See below TS error: image

What's the expected behaviour?

<Tabs> should accept null as child as documented here

Help us reproduce the bug!

Conditionally render <TabItem> within <Tab> and see TS error.

Code Snippet

let RequestTabItem: ReactElement | null = null;
  if (canViewRequests) {
    RequestTabItem = (
      <TabItem
        title={<RequestsBadge count={length} loading={isFetching} />}
        onClick={() => navigate("requests")}
      />
    );
  }
  return (
    <>
      <Tabs currentIndex={tab} onChange={handleChange} marginBottom="small">
        <TabItem title="Members" onClick={() => navigate("members")} />

        {RequestTabItem}
      </Tabs>

Additional information and screenshots

Amplify UI does correctly not log warning message when null. This is just a TS issue.

reesscot commented 1 year ago

@bestickley Thanks for reporting this, we'll get it fixed!

dbanksdesign commented 1 year ago

This should be fixed in #3270 and go out in the next release!

reesscot commented 1 year ago

Fixed by https://github.com/aws-amplify/amplify-ui/pull/3270