Skip to content

Commit

Permalink
rename with updateValue()
Browse files Browse the repository at this point in the history
  • Loading branch information
retrofox committed Feb 12, 2024
1 parent 6f2446d commit eb036e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ const withBlockBindingSupport = createHigherOrderComponent(
* Pick the prop value and setter
* from the source custom hook.
*/
const { value, setValue } = useSource( props, settings.args );
const { value, updateValue } = useSource(
props,
settings.args
);

// Create a unique key for the connector instance
const key = `${ settings.source }-${ name }-${ attrName }-${ i }`;
Expand All @@ -102,9 +105,9 @@ const withBlockBindingSupport = createHigherOrderComponent(
attrValue={ attrValue }
onAttributeChange={ useCallback(
( newPropValue ) => {
setValue?.( newPropValue );
updateValue?.( newPropValue );
},
[ setValue ]
[ updateValue ]
) }
/>
);
Expand Down
8 changes: 4 additions & 4 deletions packages/editor/src/bindings/entity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ const useSource = ( blockProps, sourceArgs ) => {
[ nameFromContext, nameFromArgs ]
);

const [ value, setValue ] = useEntityProp( kind, name, prop, id );
const [ value, updateValue ] = useEntityProp( kind, name, prop, id );

function setValueHandler( nextEntityPropValue ) {
function updateValueHandler( nextEntityPropValue ) {
// Ensure the value is a string.
if ( typeof nextEntityPropValue !== 'string' ) {
return;
}

setValue( nextEntityPropValue );
updateValue( nextEntityPropValue );
}

return {
placeholder: null,
value,
setValue: setValueHandler,
updateValue: updateValueHandler,
};
};

Expand Down

0 comments on commit eb036e5

Please sign in to comment.