Hook to abstract the logic to call viacep
npm install --save use-via-cep
import * as React from 'react'
import { useViaCep } from 'use-via-cep'
const Example = () => {
const { cep, data, setCep } = useViaCep()
return (
<div>
<input value={cep} onChange={({ target }) => setCep(target.value)} />
<pre>{JSON.stringify(data)}</pre>
</div>
)
}
MIT © lucasfloriani
This hook is created using create-react-hook.