Skip to content

Commit c433a36

Browse files
authored
fix: children prop typing on Elements component (#283)
@types/react@v18 has some breaking changes where FunctionalCompoent (FC) no longer automatically includes `children` prop typing. Including `children` on components is now a manual opt-in.
1 parent e9c29d1 commit c433a36

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/Elements.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// Must use `import *` or named imports for React's types
2-
import {FunctionComponent, ReactElement, ReactNode} from 'react';
2+
import {
3+
FunctionComponent,
4+
PropsWithChildren,
5+
ReactElement,
6+
ReactNode,
7+
} from 'react';
38
import * as stripeJs from '@stripe/stripe-js';
49

510
import React from 'react';
@@ -102,7 +107,7 @@ interface PrivateElementsProps {
102107
*
103108
* @docs https://stripe.com/docs/stripe-js/react#elements-provider
104109
*/
105-
export const Elements: FunctionComponent<ElementsProps> = (({
110+
export const Elements: FunctionComponent<PropsWithChildren<ElementsProps>> = (({
106111
stripe: rawStripeProp,
107112
options,
108113
children,
@@ -196,7 +201,7 @@ export const Elements: FunctionComponent<ElementsProps> = (({
196201
return (
197202
<ElementsContext.Provider value={ctx}>{children}</ElementsContext.Provider>
198203
);
199-
}) as FunctionComponent<ElementsProps>;
204+
}) as FunctionComponent<PropsWithChildren<ElementsProps>>;
200205

201206
Elements.propTypes = {
202207
stripe: PropTypes.any,

0 commit comments

Comments
 (0)