import { memo } from "@wordpress/element"; import { Button } from "@wordpress/components"; import { useDeviceType } from "@easy-accordion/controls"; import "./editor.scss"; const Units = ({ attributes, setAttributes, attributesKey, units }) => { const deviceType = useDeviceType(); // Set unit function. const setUnit = (newValue) => { if (attributes.unit[deviceType]) { setAttributes({ [attributesKey]: { ...attributes, unit: { ...attributes.unit, [deviceType]: newValue.toLowerCase(), }, }, }); } else { setAttributes({ [attributesKey]: { ...attributes, unit: newValue.toLowerCase(), }, }); } }; const unit = "object" === typeof attributes?.unit ? attributes.unit[deviceType] : attributes?.unit; return (