1.0.1 • Published 2 years ago

wc-react-hook v1.0.1

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

wc-react-hook

Simple wrapper to export your react components as web components to make them portable.

Install

yarn add wc-react-hook

Usage of the hook in your react

import { useWCHook } from 'wc-react-hook';
...
const Greeting = ({ name }) => <h1>Hello, {name}</h1>

Greeting.propTypes = {
  name: PropTypes.string.isRequired,
}

export default useWCHook(Greeting, 'web-greeting');

After this you can use <web-greeting name="thor"></web-greeting> as a web component.

Local Demo with parcel

yarn
yarn start

The local development server running at http://localhost:1234 that serves the basic demo is driven by index.html