Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mui-modal-provider

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mui-modal-provider

[![package version](https://img.shields.io/npm/v/mui-modal-provider.svg?style=flat-square)](https://www.npmjs.com/package/mui-modal-provider) [![package downloads](https://img.shields.io/npm/dm/mui-modal-provider.svg?style=flat-square)](https://www.npmjs.

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.3K
decreased by-28.6%
Maintainers
1
Weekly downloads
 
Created
Source

mui-modal-provider

package version package downloads standard-readme compliant package license

Install

npm install mui-modal-provider # or yarn add mui-modal-provider

Usage

App.js

import React from 'react';
import ModalProvider, { useModal } from 'mui-modal-provider';
import Blog from './components/Blog';

export default function App() {
  return (
    <ModalProvider>
      <Blog>
    </ModalProvider>
  )
}

components/Blog.js

import React from 'react';
import Button from '@material-ui/core/Button';
import { useModal } from 'mui-modal-provider';

import HelloWorldDialog from './HelloWorldDialog.js';

export default function Blog() {
  const { showModal } = useModal();

  const handleClick = () => {
    const modal = showModal(HelloWorldDialog, {
      title: 'Hello World',
      description: 'description text',
      onConfirm: () => {
        console.log('ok');
        modal.hide();
      },
      onCancel: () => {
        console.log('cancel');
        modal.hide();
      }
    });
  };

  return (
    <div>
      <Button
        variant="contained"
        onClick={handleClick}
        color="primary"
      >
        show modal
      </Button>
    <div>
  )
}

components/HelloWorldDialog.js

import React from 'react';
import DialogTitle from '@material-ui/core/DialogTitle';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import Dialog from '@material-ui/core/Dialog';
import Button from '@material-ui/core/Button';

export default function HelloWorldDialog({
  title = '',
  description = '',
  onCancel,
  onConfirm,
  ...props
}) {
  return (
    <Dialog {...props}>
      <DialogTitle>{title}</DialogTitle>
      <DialogContent>
        <DialogContentText>{description}</DialogContentText>
      </DialogContent>
      <DialogActions>
        <Button onClick={onCancel} color="primary">
          Cancel
        </Button>
        <Button onClick={onConfirm} color="primary">
          Ok
        </Button>
      </DialogActions>
    </Dialog>
  );
}

FAQs

Package last updated on 27 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc