react-stencil-wrapper
TypeScript icon, indicating that this package has built-in type declarations

0.0.10 • Public • Published

React Stencil Wrapper

This module enables you to easily wrap Stencil components in React apps, taking full advantage of life cycle hooks so events are added and removed whenever a React component is mounted and unmounted.

Example usage where 'st-button' is a Stencil component:

import { StencilComponentWrapper } from './react-stencil-wrapper';

function App() {
  const [name, setName] = useState('');

  render() {
    return (
      <div>
        <input
          type="text"
          onChange={e => setName(e.target.value)}
          name="name"
          value={name}
        />
        <hr/>
        <StencilComponentWrapper
          name={name}
          clickEvent={(e) => { console.log(`function was called ${e}`}}
          eventListeners={{
              buttonClicked: (e) =>{ console.log(`event was triggered ${e.detail}`)}}
          }}
          componentDidMountCallback={el => {
              el.focus();
          }}
        >
          <st-button>Click Me</st-button>
        </StencilComponentWrapper>
      </div>
    )
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i react-stencil-wrapper

Weekly Downloads

13

Version

0.0.10

License

MIT

Unpacked Size

23.3 kB

Total Files

10

Last publish

Collaborators

  • jagreehal