react-daumpost-hook 1.1.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -93,8 +93,8 @@ import ReactDaumPost from 'react-daumpost-hook';
93
93
  팝업 방식으로 쓰신다면 js 기반 프로젝트라면 어디서든 상관 없습니다.
94
94
  다만 타입스크립트의 사용시 리액트 기반으로 타입추론을 하고 있습니다.
95
95
 
96
- ### PROPS
97
-
96
+ ### Props
97
+ >
98
98
  > config자체를 넘기지 않을 경우 console에 검색결과를 출력 합니다.
99
99
 
100
100
  1. **`ref (?ref)`** : 다음 우편번호 찾기 검색창을 삽입시킬 컴포넌트입니다. useRef를 통해서 셀렉한 ref를 넘깁니다., **해당 속성을 비워두시면 자동으로 우편코드 검색 창을 팝업 방식**으로 띄웁니다.
@@ -117,12 +117,10 @@ import ReactDaumPost from 'react-daumpost-hook';
117
117
  자세한 내용은 [Daum Postcode API 가이드](http://postcode.map.daum.net/guide#usage)에서 참고해주시길 바랍니다.
118
118
 
119
119
  4. **`config (?object)`** : 다음 API에서 제공되는 **config들을 사용하실 경우 제공되는 인터페이스**입니다. 자세한 내용은 [Daum Postcode API 가이드](http://postcode.map.daum.net/guide#usage)에서 참고해주시길 바랍니다.
120
-
121
120
  5. **`onComplete (function)`** : API 검색 결과를 처리할 함수를 넘겨주시길바랍니다.
122
121
  `config 자체를 안넘길 경우 기본 값은 (data) => console.log(data)입니다.`
123
122
 
124
- **_ref, apiUrl, method, onComplete, config 5가지 인자_** 를 `config` 프로퍼티로 해당 커스텀훅에 넘겨서 API를 설정할 있습니다.
125
- 4가지 중 **_반드시 필요한 속성은 검색결과를 처리할 onComplete 하나_** 입니다. 를 통해서 원하는 위치에 검색창을 삽입하시거나 팝업방식으로 간단히 API를 이용가능하니 참고하셔서 사용해주시고 문의가 있을시 해당 Git Repo에 이슈로 등록해주시길 바랍니다.
123
+ **_ref, apiUrl, method, onComplete, config 5가지 인자_** 중 **_반드시 필요한 속성은 검색결과를 처리할 onComplete 하나_** 입니다. **ref** 통해서 원하는 위치에 검색창을 삽입하시거나 팝업방식으로 간단히 API를 이용가능하니 참고하셔서 사용해주시고 문의가 있을시 해당 Git Repo에 이슈로 등록해주시길 바랍니다.
126
124
 
127
125
  ### LICENSE
128
126
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-daumpost-hook",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "다음 카카오에서 무료로 제공하는 우편번호(주소찾기) API를 쉽게 기존 코드에 연결 할 수 있는 hook 패키지 입니다.",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -38,6 +38,6 @@
38
38
  },
39
39
  "homepage": "https://github.com/yoonjonglyu/react-daumpost-hook#readme",
40
40
  "dependencies": {
41
- "react": "^17.0.2"
41
+ "isa-util": "^1.0.7"
42
42
  }
43
43
  }
package/src/index.d.ts CHANGED
@@ -16,7 +16,7 @@ declare module 'react-daumpost-hook' {
16
16
 
17
17
  interface ReactDaumPostProps {
18
18
  ref?: React.MutableRefObject<any>;
19
- onComplete: (state: PostStateProps) => VoidFunction;
19
+ onComplete: (state: PostStateProps) => void;
20
20
  apiUrl?: string;
21
21
  method?: {
22
22
  onresize?: (size: { width: number; height: number }) => void;
@@ -1,3 +1,5 @@
1
+ import { loadCDN } from 'isa-util';
2
+
1
3
  function daumPostCodeHook(props) {
2
4
  const { ref, apiUrl, method, onComplete, config } = props;
3
5
 
@@ -13,19 +15,10 @@ function daumPostCodeHook(props) {
13
15
  const __config = { ...config };
14
16
 
15
17
  // 스크립트가 없을시 로드 해오는 부분
16
- if (document.getElementById(__scriptId) === null) {
17
- const __postCodeScript = document.createElement('script');
18
- __postCodeScript.id = __scriptId;
19
- __postCodeScript.src = __postcodeUrl;
20
- document.head.appendChild(__postCodeScript);
21
- }
18
+ loadCDN(__scriptId, __postcodeUrl);
22
19
 
23
20
  const getPostCode = () => {
24
- if (ref === undefined) {
25
- getPostCodePopup();
26
- } else {
27
- getPostCodeEmbed();
28
- }
21
+ ref === undefined ? getPostCodePopup() : getPostCodeEmbed();
29
22
  };
30
23
 
31
24
  const getPostCodeEmbed = () => {