It seems like you’re not using a build step to process your custom-terms-block.js
. This means you cannot use JSX syntax. Instead, you should replace all instances of JSX with React.createElement()
:
edit: (props) => {
const { terms } = props.attributes;
// Fetch terms and their associated ACF brand_logo fields
const [taxonomyTerms, error] = useEntityProp("taxonomy", "category", "terms");
if (error) {
console.error("Error fetching terms:", error);
return React.createElement("div", {}, "Error: Could not load terms");
}
const termsWithLogos = taxonomyTerms.map((term) => {
const brandLogoUrl = term.meta?.brand_logo || "";
return {
id: term.id,
name: term.name,
brandLogoUrl,
};
});
return React.createElement(
"ul",
{},
termsWithLogos.map((term) =>
React.createElement(
"li",
{ key: term.id },
term.brandLogoUrl
? React.createElement("img", {
src: term.brandLogoUrl,
alt: term.name,
})
: RichText.Content({ value: term.name }),
),
),
termsWithLogos.length === 0 &&
React.createElement("li", {}, "No terms found"),
);
};