JSPM

use-season

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q21428F
  • License MIT

React hooks to get the season based on the geo location browser api.

Package Exports

  • use-season

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (use-season) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

use-season

0 dependencies react hooks to get the season based on the browser geo location api.

Installation :

  npm install use-season

Usage :

import React from 'react';
import useSeason from 'use-season';

function App() {
  const { error, loading, season, fetchSeason } = useSeason();
  if (loading) return <p>loading...</p>;
  return (
    <>
      {error && !season && error}
      {season && !error && season}
      <button onClick={fetchSeason}> Click me </button>
    </>
  );
}

export default App;

Note :

This package is based on the browser Geolocation API so, browser will ask you to use your location in that case you must click Allow else it won't work.

Demo

Check it out !