Skip to content

Commit f6b41d7

Browse files
committed
Replace problem annotation to PR number
1 parent 08f5d57 commit f6b41d7

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

src/DaumPostcodeEmbed.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,8 @@ const defaultProps = {
4141

4242
class DaumPostcodeEmbed extends Component<DaumPostcodeEmbedProps, State> {
4343
static defaultProps = defaultProps;
44-
4544
/**
46-
* 1. 깃헙이슈_#53: DaumpostcodeEmbed 메소드 사용시 Document.write() 가 문제가 됩니다.
47-
* 2. 에러메세지: caught TypeError: Cannot read properties of null (reading 'document').
48-
* 3. 원인: `loadPostcode` 함수가 두번 실행되어 발생하는 문제입니다.
49-
* * React StrictMode에서는 의도적으로 라이프사이클 메소드가 두 번 호출되게 설계되어 있습니다.
50-
* * 이는 개발 과정에서 부작용(side-effects)이 발생하는 것을 감지하고 문제를 미리 찾아낼 수 있도록 하는 목적이 있습니다.
51-
* 4. 해결: 의도적으로 componentDidMount시 `loadPostcode` 함수가 1번만 호출하도록 변수 `mount`를 추가하여, mount값이 false 일때만 `loadPostcode`를 실행하면 해결됩니다.
52-
* @see =================== 변경 내역 ==================
53-
* [작성자][작업일시] - 내용
54-
* [HK1211][2023-05-28 Sunday 00:48:08] - 최초작성
45+
* See #61
5546
*/
5647
private mounted = false;
5748

@@ -68,7 +59,7 @@ class DaumPostcodeEmbed extends Component<DaumPostcodeEmbedProps, State> {
6859
if (!scriptUrl) return;
6960
if (!this.mounted) {
7061
loadPostcode(scriptUrl).then(initiate).catch(onError);
71-
this.mounted = true; // react@18 부터 development 환경에서 React.StrictMode 사용시 출력되는 문제해결.
62+
this.mounted = true;
7263
}
7364
}
7465

0 commit comments

Comments
 (0)