0.0.6 • Published 2 years ago
microcms-iframe-react v0.0.6
microcms-iframe-react
This library is for communicating with the microCMS iframe field via postMessage
.
postMessage
protocol is here.
This library is useful when using React.
Usage
import { useMicroCMSIframe } from "microcms-iframe-react";
export default function ColorPicker() {
const [color, setColor] = useMicroCMSIframe("#00ff00", {
origin: "https://example.microcms.io",
});
const onChangeColor = (e) => {
setColor({ id: "color", data: e.target.value });
};
return <input type="color" value={color} onChange={onChangeColor} />;
}
useMicroCMSIframe
can take the same arguments assetup
described in the README of microcms-iframe-api
.