PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.2
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.2
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 / components / iconLibrary / useIconList.js

useIconList.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.2, at src/components/iconLibrary/useIconList.js

36 lines 694 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import apiFetch from "@wordpress/api-fetch";
2 import { useEffect, useState } from "@wordpress/element";
3
4 const useIconList = () => {
5 const [icon, setIcon] = useState([]);
6
7 const fetchIconList = async () => {
8 await apiFetch({
9 path: `/smart-post/v2/icon-list`,
10 method: "POST",
11 headers: {
12 "X-WP-Nonce": sp_smart_post_block_localize.ajaxNonce,
13 },
14 data: {
15 someParam: "example",
16 },
17 })
18 .then((response) => {
19 setIcon(JSON.parse(response));
20 })
21 .catch((error) => {
22 console.error("Error fetching icon list:", error);
23 });
24 };
25
26 useEffect(() => {
27 if (icon.length < 1) {
28 fetchIconList();
29 }
30 }, [icon]);
31
32 return icon;
33 };
34
35 export default useIconList;
36