New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-custom-element-connector

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-custom-element-connector

A simple connector for custom elements that are used in react applications

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

React Custom Element Wrapper

A simple wrapper that allows you to wrap custom elements in reactjs.

Install

npm install react-custom-element-connector

Usage

Say you have a custom element hello-world created via pure-lib with a prop whoIsThere and an event knockknock that's triggered when clicked.

const who = "me";
return html`<hello-world 
    .whoIsThere=${who} 
    @knockknock=${e => console.log(e.detail)}
></hello-world>`

This element can be used like this:

const who = "me";
<CustomElement
  tag="hello-world"
  whoIsThere={who}
  knockknock={console.log}
/>

The wrapper will take care to:

  • transform camelCase attributes to dashed, as react doesn't support camelCase for attributes (this will only work if your framework supports that. @angular/elements and pure-lit do this out of the box, lit will need manual work)
  • attach an event listener to the dom event and adds it to the virtual element.

Keywords

custom-element

FAQs

Package last updated on 19 Jul 2021

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