# post-carousel/4.0.7/src/hooks/updateParentAttr.js

Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog &amp; News, version 4.0.7. 26 lines.

- Page: https://pluginprobe.com/plugins/post-carousel/4.0.7/code/src/hooks/updateParentAttr.js
- Raw: https://pluginprobe.com/plugins/post-carousel/4.0.7/raw/src/hooks/updateParentAttr.js
- Modified: 2026-04-24T11:48:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/post-carousel/4.0.7/code/src/hooks/updateParentAttr.js#L10-L20`.

```javascript
import { useEffect } from "@wordpress/element";
import { useSelect, useDispatch } from "@wordpress/data";
import { store as blockEditorStore } from "@wordpress/block-editor";

const useUpdateParentAttributes = (clientId, data) => {

	const { updateBlockAttributes } = useDispatch(blockEditorStore);

	// Get parent block id
	const parentId = useSelect((select) => {
		return select(blockEditorStore).getBlockRootClientId(clientId);
	}, [clientId]);

	useEffect(() => {

		if (parentId) {
			updateBlockAttributes(parentId, {
				multipleFilterRelation: data,
			});
		}

	}, [data, parentId]);

};

export default useUpdateParentAttributes;
```
