react-auto-mount

1.0.1 • Public • Published

React Auto Mount

A really tiny module to unobtrusively mount your components.

Usage

Throw a div in your template with a data-component attribute.

<div
  data-component='HelloWorld'
  data-props='{"name": "Ray"}'
/>

Then, invoke the reactAutoMount.

import React from 'react';
import reactAutoMount from 'react-auto-mount';
 
const HelloWorld = ({ name }) => (
  <h1>{`Hello ${name}!`}</h1>
);
 
document.addEventListener('DOMContentLoaded', () => {
  reactAutoMount({ HelloWorld });
});

Package Sidebar

Install

npm i react-auto-mount

Weekly Downloads

0

Version

1.0.1

License

ISC

Last publish

Collaborators

  • rzane