Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/DaumPostcodeEmbed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type DaumPostcodeProps = DaumPostcodeEmbedProps;

interface State {
hasError: boolean;
completed: boolean;
}

const defaultErrorMessage = <p>현재 Daum 우편번호 서비스를 이용할 수 없습니다. 잠시 후 다시 시도해주세요.</p>;
Expand All @@ -50,6 +51,7 @@ class DaumPostcodeEmbed extends Component<DaumPostcodeEmbedProps, State> {

state = {
hasError: false,
completed: false,
};

componentDidMount() {
Expand All @@ -72,7 +74,7 @@ class DaumPostcodeEmbed extends Component<DaumPostcodeEmbedProps, State> {
...options,
oncomplete: (address) => {
if (onComplete) onComplete(address);
if (autoClose && this.wrap.current) this.wrap.current.remove();
this.setState({ completed: true });
},
onsearch: onSearch,
onresize: onResize,
Expand All @@ -90,8 +92,10 @@ class DaumPostcodeEmbed extends Component<DaumPostcodeEmbedProps, State> {
};

render() {
const { className, style, errorMessage } = this.props;
const { hasError } = this.state;
const { className, style, errorMessage, autoClose } = this.props;
const { hasError, completed } = this.state;

if (autoClose === true && completed === true) return null;

return (
<div ref={this.wrap} className={className} style={{ ...defaultStyle, ...style }}>
Expand Down