react-email icon indicating copy to clipboard operation
react-email copied to clipboard

types(row, tailwind, menu): Replace explicit children typing with React's propsWithChildren generic type

Open rossreicks opened this issue 1 year ago • 2 comments

I was running into an error building a project with webpack that specifies a property and children on the Tailwind and Row components.

example code:

  <Row className='mt-6'>
          <Column>
              <Text className='text-base font-medium m-0'>{item.title}</Text>
          </Column>
          <Column>
              <Text className='text-base m-0 text-right'>{item.daysListed} Days</Text>
          </Column>
  </Row>

The webpack error:

Argument of type '{ className: string; }' is not assignable to parameter of type 'Attributes & Readonly<RowProps>'.
      Property 'children' is missing in type '{ className: string; }' but required in type 'Readonly<RowProps>'

If I manually changed the types from the package to propsWithChildren is seemed to work. It seems like webpack is not recognizing the children prop when building and the propsWithChildren allows children to be undefined.

This is specific to using a babel-loader with a babel plugin for typescript, if I ts-loader the typescript first, then babel the react, it works just fine.

It seems pretty harmless but open to any criticisms, first PR so hopefully I am following the rules.

rossreicks avatar Apr 08 '24 14:04 rossreicks

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-email-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 8, 2024 2:54pm

vercel[bot] avatar Apr 08 '24 14:04 vercel[bot]

@rossreicks is attempting to deploy a commit to the resend Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Apr 08 '24 14:04 vercel[bot]

Why did you close it?

gabrielmfern avatar Aug 02 '24 16:08 gabrielmfern