Skip to content

Commit

Permalink
Fix initial value assignment in BlockBindingConnector
Browse files Browse the repository at this point in the history
  • Loading branch information
michalczaplinski committed Feb 14, 2024
1 parent d1dcae1 commit 5d5bbdb
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const BlockBindingConnector = ( {
blockProps,
args,
} ) => {
const lastPropValue = useRef();
const lastAttrValue = useRef();
const { value, updateValue } = useSource( blockProps, args );
const lastPropValue = useRef( value );
const lastAttrValue = useRef( attrValue );

const setAttributes = blockProps.setAttributes;

Expand All @@ -49,6 +49,13 @@ const BlockBindingConnector = ( {
[ attrName, setAttributes ]
);

/* Set the initial value of the block attribute */
useEffect( () => {
setAttributes( {
[ attrName ]: value,
} );
}, [] );

/*
* Source Prop => Block Attribute
*
Expand Down

0 comments on commit 5d5bbdb

Please sign in to comment.