Coder Social home page Coder Social logo

use-cep-hook's Introduction

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

use-cep-hook's People

Contributors

dependabot[bot] avatar mateusandrade avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

use-cep-hook's Issues

You can use cep-promise

Description

That's actually not an Issue, but rather an suggestion ๐Ÿ˜ฌ

Right now your hook relies only at ViaCep to reply to it's user, and if there's any outage at ViaCep your hook simply wont work.

In order to solve this you might update your integration to use https://www.npmjs.com/package/cep-promise that will simplify all your logic and also provide integration with:

  • ViaCep
  • Correios
  • WideNet

The module will fetch the data form all providers and return as soon as at least one of the services reply =)

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @testing-library/jest-dom to v5.17.0
  • chore(deps): update dependency @testing-library/react to v14.1.2
  • chore(deps): update dependency eslint to v8.55.0
  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update commitlint monorepo to v18 (major) (@commitlint/cli, @commitlint/config-conventional)
  • chore(deps): update dependency @testing-library/jest-dom to v6
  • chore(deps): update dependency @types/node to v20
  • chore(deps): update dependency gh-pages to v6
  • chore(deps): update dependency husky to v8
  • chore(deps): update dependency lint-staged to v15
  • chore(deps): update dependency prettier to v3
  • chore(deps): update dependency typescript to v5
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/actions.yml
  • actions/checkout v3
  • actions/setup-node v2
  • actions/cache v3
npm
package.json
  • cep-promise ^4.0.0
  • @commitlint/cli 17.6.1
  • @commitlint/config-conventional 17.6.1
  • @testing-library/jest-dom 5.16.5
  • @testing-library/react 14.0.0
  • @testing-library/user-event 13.5.0
  • @types/jest 27.4.1
  • @types/node 16.18.21
  • @types/react 18.0.31
  • @types/react-dom 18.0.11
  • eslint 8.36.0
  • eslint-plugin-react 7.29.4
  • gh-pages 3.2.3
  • husky 7.0.4
  • lint-staged 12.3.7
  • prettier 2.8.7
  • react 18.2.0
  • react-dom 18.2.0
  • react-scripts 5.0.1
  • typescript 4.9.5

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.