npm.io
1.1.1 • Published 3 years ago

react-custom-mount

Licence
MIT
Version
1.1.1
Deps
0
Size
40 kB
Vulns
0
Weekly
0

react-custom-mount

Mount react components using custom elements

NPM JavaScript Style Guide

Install

npm install --save react-custom-mount

Usage

import {
    registerCustomElement,
    registerCustomElements,
    Components
} from 'react-custom-mount'

const ComponentOne = ({ myAttribute, children }) => {
    return (
        <>
            <p>Hello {myAttribute}</p>
            {children}
        </>
    )
}

const components: Components = {
    'component-one': ComponentOne
}

document.addEventListener('DOMContentLoaded', function () {
    // Register multiple components
    registerCustomElements(componenets)

    // Or one
    registerCustomElement('component-one', ComponentOne)
})
<component-one my-attribute="hello">
    <div>
        <p>From the other side</p>
    </div>
</component-one>

License

MIT Borhaneddine GUEMIDI, Sofiane DEBBAGH