File tree Expand file tree Collapse file tree 6 files changed +22
-36
lines changed
Expand file tree Collapse file tree 6 files changed +22
-36
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @shinyongjun/react-dialog" ,
3- "version" : " 1.0.3 " ,
3+ "version" : " 1.1.0 " ,
44 "main" : " ./dist/cjs/index.js" ,
55 "module" : " ./dist/esm/index.js" ,
66 "source" : " ./src/index.tsx" ,
Original file line number Diff line number Diff line change 1+ import { useContext } from 'react' ;
2+ import AlertContext from '../context/AlertContext' ;
3+ import ConfirmContext from '../context/ConfirmContext' ;
4+ import PromptContext from '../context/PromptContext' ;
5+
6+ const useDialog = ( ) => {
7+ const { alert } = useContext ( AlertContext ) ;
8+ const { confirm } = useContext ( ConfirmContext ) ;
9+ const { prompt } = useContext ( PromptContext ) ;
10+
11+ return { alert, confirm, prompt } ;
12+ } ;
13+
14+ export default useDialog ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- export { default as AlertDialog } from './components/dialog/AlertDialog' ;
2- export { default as ConfirmDialog } from './components/dialog/ConfirmDialog' ;
3- export { default as PromptDialog } from './components/dialog/PromptDialog' ;
41export { default as AlertContext } from './context/AlertContext' ;
52export { default as ConfirmContext } from './context/ConfirmContext' ;
63export { default as PromptContext } from './context/PromptContext' ;
4+ export { default as useDialog } from './hooks/useDialog' ;
75export { default as DialogProvider } from './components/DialogProvider' ;
Original file line number Diff line number Diff line change 11import * as React from 'react' ;
2- import { useContext } from 'react' ;
3- import {
4- AlertContext ,
5- ConfirmContext ,
6- PromptContext ,
7- } from '@shinyongjun/react-dialog' ;
2+ import { useDialog } from '@shinyongjun/react-dialog' ;
83import '@shinyongjun/react-dialog/css' ;
94
105function App ( ) {
11- const { alert : customAlert } = useContext ( AlertContext ) ;
12- const { confirm : customConfirm } = useContext ( ConfirmContext ) ;
13- const { prompt : customPrompt } = useContext ( PromptContext ) ;
6+ const {
7+ alert : customAlert ,
8+ confirm : customConfirm ,
9+ prompt : customPrompt ,
10+ } = useDialog ( ) ;
1411
1512 const onAlertClick = async ( ) => {
1613 await customAlert ( 'are you sure?' ) ;
You can’t perform that action at this time.
0 commit comments