Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4938964

Browse files
committedNov 3, 2024
change EditableElement type to accept class components too
1 parent 83a3dd3 commit 4938964

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

‎src/ui/fields/editable.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @module ui
33
*/
4-
import { Fragment, FunctionComponent, VNode } from "preact";
4+
import { ComponentType, Fragment, VNode } from "preact";
55
import { Dispatch, Reducer, useContext, useEffect, useMemo, useRef } from "preact/hooks";
66
import { ChangeEvent, useReducer } from "preact/compat";
77
import Select, { ActionMeta } from "react-select";
@@ -50,8 +50,8 @@ export interface EditableProps<T> {
5050
}
5151

5252
type EditableElementProps<T, P> = EditableState<T> & P;
53-
export type EditableElement<T, P = any> = FunctionComponent<EditableElementProps<T, P> & P>;
54-
53+
export type EditableElement<T, P = any> = ComponentType<EditableElementProps<T, P> & P>;
54+
5555
/**
5656
* Actions which update/change the state of an editable.
5757
*
@@ -136,14 +136,14 @@ export function ControlledEditable<T, P = unknown>({
136136
editor: Editor,
137137
onUpdate,
138138
content,
139-
props,
140-
sourcePath
139+
props,
140+
sourcePath,
141141
}: Omit<EditableProps<T>, "dispatch" | "state" | "editor"> & {
142142
onUpdate: (v: T) => unknown;
143143
content: T;
144144
editor: EditableElement<T, P>;
145-
props: P;
146-
sourcePath: string;
145+
props: P;
146+
sourcePath: string;
147147
}) {
148148
const [state, dispatch] = useEditableDispatch<T>(() => ({
149149
updater: onUpdate,

0 commit comments

Comments
 (0)
Please sign in to comment.