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

[component] cannot be used as a JSX component #398

Closed
vrugtehagel opened this issue Apr 8, 2022 · 5 comments
Closed

[component] cannot be used as a JSX component #398

vrugtehagel opened this issue Apr 8, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@vrugtehagel
Copy link

Describe the bug
In version 6.0.0 of @stripe/ui-extension-sdk, components do not have the correct type definitions. Running the TypeScript compiler throws an error for every component, e.g.

error TS2786: 'Box' cannot be used as a JSX component.
  Its element type 'ReactElement<any, any> | Component<ReactPropsFromRemoteComponentType<RemoteComponentType<"Box", StylableProps, true>>, any, any> | null' is not a valid JSX element.

         <Box />
          ~~~

To Reproduce
Create a new app through stripe apps create helloworld. When set up, run the TypeScript compiler.

Expected behavior
No errors are thrown.

Desktop (please complete the following information):
MacOS Monterey

@vrugtehagel vrugtehagel added bug Something isn't working needs-triage labels Apr 8, 2022
@ericfrank-stripe
Copy link
Collaborator

Hi @vrugtehagel, I'm not able to reproduce this issue. Here's my full test case:

import {Box} from '@stripe/ui-extension-sdk/ui';
const App = () => {
  return (
    <Box />
  );
};

Running yarn tsc is successful. Would you mind posting your app code?

@ericfrank-stripe ericfrank-stripe self-assigned this Apr 8, 2022
@ericfrank-stripe
Copy link
Collaborator

@vrugtehagel I just figured out how to reproduce this by force installing all new packages. Looking into the issue now.

@ericfrank-stripe
Copy link
Collaborator

ericfrank-stripe commented Apr 8, 2022

It looks like the issue is due to the wrong React types package (v18) being pulled in by one of our dependencies. We're looking into a permanent fix, but for now you can add a resolutions section for yarn or an overrides section for npm to your package.json to force the correct version:

yarn

{
  "resolutions": {
    "@types/react": "^17.0.2"
  }
}

npm

{
  "overrides": {
    "@types/react": "^17.0.2"
  }
}

Delete yarn.lock and node_modules and do a fresh install. I'll update this issue when we have a permanent fix.

@ericfrank-stripe
Copy link
Collaborator

The root cause: facebook/react#24304

@ericfrank-stripe
Copy link
Collaborator

Created a notice about this issue here: #402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants