🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

react-to-custom-element

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-to-custom-element

Convert React components to custom elements

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

react-to-custom-element

Converts your React component into a custom element that you can register using customElements.define. Props are parsed and handled within the converter such that camel-case names are retained and you don't have to register any custom event handlers for props that start with on.

This library leverages the parsing capability in React 19.

Install

npm i react-to-custom-element

Usage

const element = reactToCustomElement(CustomElement, {
  properties: [
    "propString",
    "propNumber",
    "propBoolean",
    "propObject",
    "propArray",
    "propFunction",
    "onMyEvent",
  ],
  attributes: ["my-first-attribute", "my-second-attribute"],
});

customElements.define("custom-element", element);

Keywords

react

FAQs

Package last updated on 01 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts