Skip to content

MateusAndrade/use-cep-hook

Repository files navigation

use-cep-hook 🌎

npm

This is a simple React Hooks that let you search for a brazillian postal-code.

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 useCep from "use-cep-hook";

const Foo = () => {
  const [postalCode, setPostalCode] = useState("");

  const [loading, cep, error] = useCep(postalCode);

  return (
    <div className="field">
      <label>CEP:</label>
      <input onChange={e => setPostalCode(e.target.value)} value={postalCode} />
    </div>
  );
};

Every time that a valid CEP is passed to this hooks, this will cause a side effect that will search for the updated value.

You can check the full implementation here!

TODO:

  • Port to TS
  • Apply some cool CSS to example
  • Write TESTS!
  • Deploy example to GH pages!
  • Configure Github Actions

About

Brazilian CEP info on a elegant way! 🙀 🔍 📫

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •