1.0.0 • Published 2 years ago

microcms-field-extension-react v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

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.

1.0.0

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago