GitXplorerGitXplorer
r

use-viacep

public
12 stars
2 forks
10 issues

Commits

List of commits on branch master.
Verified
528536b2b95a95d2443bec6c31bd8e4cbde01cc6

Merge pull request #251 from raisiqueira/next

rraisiqueira committed 2 years ago
Unverified
89b7837762bfce5a6d66517570144cd700834eee

chore: fix lock file

rraisiqueira committed 2 years ago
Unverified
c636a051331af6a11840a2cc00721a073a1c0212

Merge branch 'master' of github.com:raisiqueira/use-viacep into next

rraisiqueira committed 2 years ago
Unverified
175818ef49872e0364408563cc3451c74684dbfb

chore: update readme

rraisiqueira committed 2 years ago
Verified
5d6a912c24a508636f15aa4a031c5bcd094634d4

chore: update tsup version (#240)

rraisiqueira committed 2 years ago
Verified
48245ff563e91ba91b2f480df302a7bc6d9f57c7

chore: bump dev dependencies version (#237)

rraisiqueira committed 2 years ago

README

The README file for this repository.

useViaCep

use-viacep

React hook to fetch Brazilian CEP's using ViaCEP api.

Install

npm i --save @rsiqueira/use-viacep # or yarn add @rsiqueira/use-viacep

Usage

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import useViaCep from '@rsiqueira/use-viacep';

const App = () => {
  const [data, setData] = React.useState('');
  const { cep, loading, error } = useViaCep(data);

  if (loading) {
    return <p>loading...</p>;
  }

  return (
    <div>
      <input placeholder="cep" onChange={(e) => setData(e.target.value)} />
    </div>
  );
};

ReactDOM.render(<App />, document.getElementById('root'));

Contributing

Clone this repository and run pnpm install. If you don't have pnpm, install it with npm install -g pnpm.

Folder structure

  • example - A folder with an example project. Think as playground.
  • lib - The source of @rsiqueira/use-viacep.

What is in this repository?

  • PNPM as workspace manager and package manager.
  • TSUP as a TypeScript universal package.
  • Vitest as a test runner.
  • Size Limit as a size limit plugin.
  • Prettier as a code formatter.
  • ESLint as a code linter.

Using the Playground

In the root of the repository, run the following command:

pnpm run dev # to build the library (with --watch flag)
pnpm -F example dev

The command will run the example project with Vite.

Sponsors

Sponsors

License

MIT @ Rai Siqueira