This is a simple React Hooks that let you search for a brazillian postal-code on: https://viacep.com.br.
Installation
Just run a yarn add use-cep-hook
or npm i --save use-cep-hook
How to use
Simply import use-cep-hook
on your component, then call this on that way:
import useViaCep from "use-cep-hook"; const Foo = const postalCode setPostalCode = ; const loading cep error = ; return <div ="field"> <label>CEP:</label> <input = = /> </div> ;;
Every time that the argument passed to the hooks get a length of 8, this will trigger a call to the API, changing the loading
param to true
.
TODO:
- Port to TS
- Apply some cool CSS to
example
- Write TESTS!
- Deploy example to
surge.sh
! - Configure Github Actions