This library is for communicating with the microCMS iframe field via `postMessage`.
npm install microcms-field-extension-reactThis library is for communicating with the microCMS iframe field via postMessage.
postMessage protocol is here.
This library is useful when using React.
``sh`
npm install microcms-field-extension-api microcms-field-extension-react
`jsx
import { useFieldExtension } from "microcms-field-extension-react";
export default function ColorPicker() {
const { data, sendMessage } = useFieldExtension("#00ff00", {
origin: "https://example.microcms.io",
});
const onChangeColor = (e) => {
sendMessage({ id: "color", data: e.target.value });
};
return ;
}
`
useFieldExtension can take the same arguments assetup described in the README of microcms-field-extension-api`.