Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 646 Bytes

README.md

File metadata and controls

24 lines (18 loc) · 646 Bytes

Example of how to create a standalone react component that can be imported in an app that uses a script tag to load react.

Run npm install and then npm run build in order to generate the artifact. The script can be included into another application like:

<script src="my/generated/build/index.js" type="text/javascript"></script>

It exposes an object with like:

var MyReactLibrary = {
  MyJsxComponent
}

Then in the other application you have to load the React element like:

ReactDOM.render(
  React.createElement(MyReactLibrary.MyJsxComponent),
  document.getElementById('react-root')
);