react-hook-usecep
v1.0.6
Published
a react hook to get address information
Downloads
20
Readme
useCep react hook
useCep is a react hook for get address information from viacep,
Installation
npm install react-hook-usecep -S
Import
import useCep from 'react-hook-usecep';
Usage
function MyReactComponent(){
const [status, setCep] = useCep()
return (<input type="text" onBlur={(e)=>{ setCep(e.target.value) }} />)
}
Status object
{
"loading": false,
"error": false,
"data": {
"cep": "01001-000",
"logradouro": "Praça da Sé",
"complemento": "lado ímpar",
"bairro": "Sé",
"localidade": "São Paulo",
"uf": "SP",
"ibge": "3550308",
"gia": "1004",
"ddd": "11",
"siafi": "7107"
}
}