Skip to content

Commit 5d5bbdb

Browse files
Fix initial value assignment in BlockBindingConnector
1 parent d1dcae1 commit 5d5bbdb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/block-editor/src/components/block-binding-support/with-block-binding-support.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ const BlockBindingConnector = ( {
3434
blockProps,
3535
args,
3636
} ) => {
37-
const lastPropValue = useRef();
38-
const lastAttrValue = useRef();
3937
const { value, updateValue } = useSource( blockProps, args );
38+
const lastPropValue = useRef( value );
39+
const lastAttrValue = useRef( attrValue );
4040

4141
const setAttributes = blockProps.setAttributes;
4242

@@ -49,6 +49,13 @@ const BlockBindingConnector = ( {
4949
[ attrName, setAttributes ]
5050
);
5151

52+
/* Set the initial value of the block attribute */
53+
useEffect( () => {
54+
setAttributes( {
55+
[ attrName ]: value,
56+
} );
57+
}, [] );
58+
5259
/*
5360
* Source Prop => Block Attribute
5461
*

0 commit comments

Comments
 (0)