question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TS error: 'StripeProvider' cannot be used as a JSX componen

See original GitHub issue

Describe the bug Typescript error when using <StripeProvider> component

TS2786: 'StripeProvider' cannot be used as a JSX component.   Its return type 'ReactElement<any, string | ((props: any) => ReactElement<any, any> | null) | (new (props: any) => Component<any, any, any>)> | ReactElement<any, string | ... 1 more ... | (new (props: any) => Component<...>)>[]' is not a valid JSX element.     Type 'ReactElement<any, string | ((props: any) => ReactElement<any, any> | null) | (new (props: any) => Component<any, any, any>)>[]' is missing the following properties from type 'Element': type, props, key

To Reproduce Add a basic <StripeProvider publishableKey={...} merchantIdentifier={...}> component to App.

Expected behavior No typescript errors.

Additional context Library version: 0.2.3 This bug was not present on previous version 0.2.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

19reactions
dahlbykcommented, Jan 20, 2022

Is there an ETA on a new release?

In the meantime, this is what I came up with to avoid patching node_modules:

import { StripeProvider as _StripeProvider } from '@stripe/stripe-react-native';
import type { Props as StripeProviderProps } from '@stripe/stripe-react-native/lib/typescript/src/components/StripeProvider';
const StripeProvider = _StripeProvider as React.FC<StripeProviderProps>;
1reaction
te-onlinecommented, Jan 5, 2022

Changing the return type to React.ReactElement seems to work for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Component cannot be used as a JSX component. Its return ...
I'm currently getting the following error on the Todos component inside TodoApp.tsx : 'Todos' cannot be used as a JSX component.
Read more >
@stripe/stripe-react-native
Defined in src/components/StripeProvider.tsx:29 ... An optional object that contains data related to the payment method used to confirm this payment.
Read more >
'errormessage' cannot be used as a jsx component. - You.com
Only ReactPaginage and Formik ErrorMessage components give this error. windows 11; Node v16.14.2; vs code 1.66.1; react 17.0.2; typescript 4.6.3. enter image ...
Read more >
React Stripe.js reference | Stripe Documentation
Once the stripe prop has been set, these options can't be changed. If you want to use Payment Element, it is required to...
Read more >
Stripe React Native SDK - npm
Start using @stripe/stripe-react-native in your project by running ... Stripe in your React Native app, use the StripeProvider component in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found