Skip to content

Commit

Permalink
Rename onUpdate to onChange
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Jul 3, 2024
1 parent ffab101 commit 3747020
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions packages/dataviews/src/dataform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,38 @@ type DataFormProps< Item > = {
data: Item;
fields: Field< Item >[];
form: Form;
onUpdate: Dispatch< SetStateAction< Item > >;
onChange: Dispatch< SetStateAction< Item > >;
};

type DataFormControlProps< Item > = {
data: Item;
field: NormalizedField< Item >;
onUpdate: Dispatch< SetStateAction< Item > >;
onChange: Dispatch< SetStateAction< Item > >;
};

function DataFormTextControl< Item >( {
data,
field,
onUpdate,
onChange,
}: DataFormControlProps< Item > ) {
const { id, header, placeholder } = field;
const value = field.getValue( { item: data } );

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

return (
<TextControl
label={ header }
placeholder={ placeholder }
value={ value }
onChange={ onChange }
onChange={ onChangeControl }
/>
);
}
Expand Down Expand Up @@ -80,7 +80,7 @@ export default function DataForm< Item >( {
data,
fields,
form,
onUpdate,
onChange,
}: DataFormProps< Item > ) {
const visibleFields = useMemo(
() =>
Expand All @@ -99,7 +99,7 @@ export default function DataForm< Item >( {
key={ field.id }
data={ data }
field={ field }
onUpdate={ onUpdate }
onChange={ onChange }
/>
) : null;
} );
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/post-actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ const useDuplicatePostAction = ( postType ) => {
data={ item }
fields={ fields }
form={ form }
onUpdate={ setItem }
onChange={ setItem }
/>
<HStack spacing={ 2 } justify="end">
<Button
Expand Down

0 comments on commit 3747020

Please sign in to comment.