DefinitelyTyped/types/react-daum-postcode/react-daum-postcode-tests.tsx
2017-07-16 18:30:13 +09:00

29 lines
780 B
TypeScript

import * as React from 'react';
import DaumPostcode from 'react-daum-postcode';
class Postcode extends React.Component<any, any> {
handleAddress = (data: any) => {
let fullAddress: string = data.address;
let extraAddress = '';
if (data.addressType === 'R') {
if (data.bname !== '') {
extraAddress += data.bname;
}
if (data.buildingName !== '') {
extraAddress += (extraAddress !== '' ? `, ${data.buildingName}` : data.buildingName);
}
fullAddress += (extraAddress !== '' ? ` (${extraAddress})` : '');
}
console.log(fullAddress); // e.g. '서울 성동구 왕십리로2길 20 (성수동1가)'
}
render() {
return (
<DaumPostcode
onComplete={this.handleAddress}
/>
);
}
}