Skip to content

tawsbob/react-hook-useCep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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": "",
		  "localidade": "São Paulo",
		  "uf": "SP",
		  "ibge": "3550308",
		  "gia": "1004",
		  "ddd": "11",
		  "siafi": "7107"
		}
}