Skip to content

Commit

Permalink
Type onUpdate updater function
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Jul 3, 2024
1 parent 5ff77a7 commit d5b7c23
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/dataviews/src/dataform.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import type { Dispatch, SetStateAction } from 'react';

/**
* WordPress dependencies
*/
Expand All @@ -15,13 +20,13 @@ type DataFormProps< Item > = {
data: Item;
fields: Field< Item >[];
form: Form;
onUpdate: any; // TODO: fix this type.
onUpdate: Dispatch< SetStateAction< Item > >;
};

type DataFormControlProps< Item > = {
data: Item;
field: NormalizedField< Item >;
onUpdate: any; // TODO: fix this type.
onUpdate: Dispatch< SetStateAction< Item > >;
};

function DataFormTextControl< Item >( {
Expand All @@ -34,7 +39,7 @@ function DataFormTextControl< Item >( {

const onChange = useCallback(
( newValue: string ) =>
onUpdate( ( prevItem: any ) => ( {
onUpdate( ( prevItem: Item ) => ( {
...prevItem,
[ id ]: newValue,
} ) ),
Expand Down

0 comments on commit d5b7c23

Please sign in to comment.