Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 14c5e1a

Browse files
authored
feat: make some component types compatible with react 18 (#383)
* feat: make some component types compatible with react 18 * feat: make some component types compatible with react 18 * feat: make some component types compatible with react 18
1 parent 0d86696 commit 14c5e1a

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/components/Form/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import styled from '../../utils/styled';
33
import { Prompt } from '../Prompt';
44
import { FormContext, FormContextType, FormValueNotifier, FormValueChange } from '../../contexts';
55
import { StandardProps } from '../../common';
6+
import { ReactComponentDefaultProps } from '../../utils/react-18-compat';
67

78
export interface FormSubmitEvent {
89
/**
@@ -50,7 +51,7 @@ export interface FormValidationError {
5051
error: React.ReactChild;
5152
}
5253

53-
export interface FormProps<FormValues> extends StandardProps {
54+
export interface FormProps<FormValues> extends StandardProps, ReactComponentDefaultProps {
5455
/**
5556
* Shows the given message if the user wants to navigate
5657
* with changes being made or renders custom component with message if provided.
@@ -351,6 +352,7 @@ export class Form<Values extends FormValuesData> extends React.Component<FormPro
351352
prompt,
352353
...rest
353354
} = this.props;
355+
354356
const { changed } = this.state;
355357
return (
356358
<StyledForm {...rest} onSubmit={this.submit}>

src/components/PaddedContainer/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as React from 'react';
22
import styled, { css } from '../../utils/styled';
33
import { distance } from '../../distance';
4+
import { ReactComponentDefaultProps } from '../../utils/react-18-compat';
45

5-
export interface PaddedContainerProps {
6+
export interface PaddedContainerProps extends ReactComponentDefaultProps {
67
/**
78
* Padding on top. Valid values: xxsmall, xsmall, small, medium, large, xlarge, xxlarge, xxxlarge.
89
*/

src/utils/react-18-compat.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as React from 'react';
2+
3+
/**
4+
* This interface needs to be added to a property type that is used on `React.Component`.
5+
*
6+
* With React 18, React.Component and React.FC don't include children types anymore.
7+
*/
8+
export interface ReactComponentDefaultProps {
9+
children?: React.ReactNode | undefined;
10+
}

0 commit comments

Comments
 (0)