1.0.2 • Published 1 year ago

mount-components v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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