microcms-field-extension-react
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

microcms-field-extension-react

This library is for communicating with the microCMS iframe field via postMessage.

postMessage protocol is here.

This library is useful when using React.

Install

npm install microcms-field-extension-api microcms-field-extension-react

Usage

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 <input type="color" value={data} onChange={onChangeColor} />;
}

useFieldExtension can take the same arguments assetup described in the README of microcms-field-extension-api.

Readme

Keywords

none

Package Sidebar

Install

npm i microcms-field-extension-react

Weekly Downloads

149

Version

1.1.0

License

MIT

Unpacked Size

15.8 kB

Total Files

5

Last publish

Collaborators

  • tomoyaonishi
  • nemuvski