Skip to content

Commit 12964e5

Browse files
committed
chore(react-monaco-editor): resolve issues related to React 18 types
1 parent 0a58924 commit 12964e5

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

packages/react-monaco-editor/src/components/EditorErrorHandler.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ interface IEditorErrorBoundaryState {
2222
* The example preview should be rendered as a child of this component. (This component can't just
2323
* render the preview directly because error boundaries only catch errors in passed-in children.)
2424
*/
25-
export class EditorErrorBoundary extends React.Component<IEditorErrorBoundaryProps, IEditorErrorBoundaryState> {
25+
export class EditorErrorBoundary extends React.Component<
26+
React.PropsWithChildren<IEditorErrorBoundaryProps>,
27+
IEditorErrorBoundaryState
28+
> {
2629
public state: IEditorErrorBoundaryState = {};
2730
private _lastGoodChildren: React.ReactNode;
2831
private _lastErrorTime: number | undefined;

packages/react-monaco-editor/src/components/EditorWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ export const EditorWrapper: React.FunctionComponent<IEditorWrapperProps> = props
7979
);
8080
};
8181

82-
const EditorPreview: React.FunctionComponent<{}> = props => {
83-
return <div {...props} />;
82+
const EditorPreview: React.FunctionComponent<React.PropsWithChildren<unknown>> = props => {
83+
return <div {...props}>{props.children}</div>;
8484
};

packages/react-monaco-editor/src/components/EditorWrapper.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface IEditorWrapperProps {
1212
editorClassName?: string;
1313

1414
/** Custom component for the preview. It **must** render the children passed in. */
15-
previewAs?: React.ComponentType<{}>;
15+
previewAs?: React.ComponentType<React.PropsWithChildren>;
1616

1717
/** Props to use on the wrapper for the rendered example. */
1818
previewProps?: {};

packages/react-monaco-editor/src/components/TypeScriptSnippet.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export interface ITypeScriptSnippetProps {
7373
}
7474

7575
/** TypeScript code snippet with a theme similar to Monaco's VS light. */
76-
export const TypeScriptSnippet: React.FunctionComponent<ITypeScriptSnippetProps> = props => {
76+
export const TypeScriptSnippet: React.FunctionComponent<React.PropsWithChildren<ITypeScriptSnippetProps>> = props => {
7777
return (
7878
<SyntaxHighlighter className={css(rootClass, props.className)} language="tsx" style={style}>
7979
{props.children}

0 commit comments

Comments
 (0)