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 1
1
{
2
2
"name" : " @shinyongjun/react-dialog" ,
3
- "version" : " 1.0.3 " ,
3
+ "version" : " 1.1.0 " ,
4
4
"main" : " ./dist/cjs/index.js" ,
5
5
"module" : " ./dist/esm/index.js" ,
6
6
"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' ;
4
1
export { default as AlertContext } from './context/AlertContext' ;
5
2
export { default as ConfirmContext } from './context/ConfirmContext' ;
6
3
export { default as PromptContext } from './context/PromptContext' ;
4
+ export { default as useDialog } from './hooks/useDialog' ;
7
5
export { default as DialogProvider } from './components/DialogProvider' ;
Original file line number Diff line number Diff line change 1
1
import * 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' ;
8
3
import '@shinyongjun/react-dialog/css' ;
9
4
10
5
function 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 ( ) ;
14
11
15
12
const onAlertClick = async ( ) => {
16
13
await customAlert ( 'are you sure?' ) ;
You can’t perform that action at this time.
0 commit comments