Skip to content

Commit 24ea373

Browse files
author
신용준
committed
feat: 사용법 변경 useContext => useDialog
1 parent dbd87cf commit 24ea373

File tree

6 files changed

+22
-36
lines changed

6 files changed

+22
-36
lines changed

package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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",

package/src/hooks/useDialog.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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;

package/src/hooks/useOutsideClick.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

package/src/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
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';
41
export { default as AlertContext } from './context/AlertContext';
52
export { default as ConfirmContext } from './context/ConfirmContext';
63
export { default as PromptContext } from './context/PromptContext';
4+
export { default as useDialog } from './hooks/useDialog';
75
export { default as DialogProvider } from './components/DialogProvider';

package/src/methods/alert.ts

Whitespace-only changes.

test/src/App.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
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';
83
import '@shinyongjun/react-dialog/css';
94

105
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();
1411

1512
const onAlertClick = async () => {
1613
await customAlert('are you sure?');

0 commit comments

Comments
 (0)