Skip to content

scherler/wc-react-hook

Repository files navigation

wc-react-hook

Simple wrapper to export your react components as web components to make them portable. Build on top of https://github.com/bitovi/react-to-webcomponent

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

About

just a test to add react and use it to create webcomponents

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published