1.2.3 • Published 3 years ago

material-ui-confirmation v1.2.3

Weekly downloads
109
License
MIT
Repository
github
Last release
3 years ago

material-ui-confirmation

React hook to seamlessly use customizable confirmation dialogs from @material-ui/core without managing any open/close state

NPM JavaScript Style Guide

Install

npm install --save material-ui-confirmation
yarn add material-ui-confirmation

Usage

Wrap your app with the ConfirmationDialogProvider

import React from 'react';
import ReactDOM from 'react-dom';
import { ConfirmationDialogProvider } from 'material-ui-confirmation';

import App from './App';

ReactDOM.render(
  <ConfirmationDialogProvider>
    <App />
  </ConfirmationDialogProvider>,
  document.getElementById('root'),
);

Then use the useConfirmationDialog hook anywhere down the line

import React from 'react';

import { useConfirmationDialog } from 'material-ui-confirmation';

const App = () => {
  const { getConfirmation } = useConfirmationDialog();

  return (
    <button
      onClick={() => {
        getConfirmation({
          title: 'Is it working?',
          body: "Let's check if it is working",
          onAccept: () => {
            alert('Accepted');
          },
          onDecline: () => {
            alert('Declined');
          },
          dialogProps: {
            disableBackdropClick: true,
          },
          acceptButtonProps: {
            autoFocus: false,
            variant: 'contained',
          },
          declineText: 'Leave me alone',
        });
      }}
    >
      Confirm
    </button>
  );
};

export default App;

API Reference

Coming Soon

License

MIT © drenther


This hook is created using create-react-hook.

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago