npm.io
1.0.2 • Published 3 years ago

mount-components

Licence
MIT
Version
1.0.2
Deps
0
Size
1.3 MB
Vulns
0
Weekly
0
Stars
1

mounted-components

Programmatically mounting and displaying components.

NPM JavaScript Style Guide

Install

npm install --save mounted-components

Usage

import React from "react";
import { useMount, MountRoot } from "mount-components";

const Modal = ({ close, content }) => {
  return (
    <div>
      {content}
      <button onClick={close}>close</button>
    </div>
  );
};

const App = () => {
  const { open } = useMount();
  function onClick(e) {
    open(Modal, {
      content: "This is a modal!",
    });
  }
  return (
    <div>
      <button onClick={onClick}>Open</button>
      <MountRoot />
    </div>
  );
};
export default App;

License

MIT PlatzerT