1.0.2 • Published 1 year ago
mount-components v1.0.2
mounted-components
Programmatically mounting and displaying components.
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