PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.7
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.7
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / src / hooks / updateParentAttr.js

updateParentAttr.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.7, at src/hooks/updateParentAttr.js

26 lines 640 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useEffect } from "@wordpress/element";
2 import { useSelect, useDispatch } from "@wordpress/data";
3 import { store as blockEditorStore } from "@wordpress/block-editor";
4
5 const useUpdateParentAttributes = (clientId, data) => {
6
7 const { updateBlockAttributes } = useDispatch(blockEditorStore);
8
9 // Get parent block id
10 const parentId = useSelect((select) => {
11 return select(blockEditorStore).getBlockRootClientId(clientId);
12 }, [clientId]);
13
14 useEffect(() => {
15
16 if (parentId) {
17 updateBlockAttributes(parentId, {
18 multipleFilterRelation: data,
19 });
20 }
21
22 }, [data, parentId]);
23
24 };
25
26 export default useUpdateParentAttributes;