use-cep
A React hook for loading CEP data. It uses cep-promise
under the hood.
Installation
npm install use-cep
yarn add use-cep
Usage
// Using the hookconst fetch loading error data =
Here's an example with react-final-form
:
import React from 'react'import Form Field from 'react-final-form'import useCep from 'use-cep' { const fetch loading error data = return <Form > handleSubmit form <form => <Field ='cep' ='CEP' > input meta ...props <input = /> </Field> <Field ='state' ='input' ='State' = /> <Field ='city' ='input' ='City' = /> <Field ='neighborhood' ='input' ='Neighborhood' = /> </form> </Form> }