A plugable React component to display a general purpose GitHub-like contributions graph based on SVG.
npm i react-github-heatmap
yarn add react-github-heatmap
Take a glance at the docs to see further examples 😉.
import React from 'react';
import { Heatmap, HeatmapData } from 'react-github-heatmap';
import { api } from './api';
const App = () => {
const [data, setData] = React.useState<HeatmapData>();
const [isLoading, setIsLoading] = useState(false);
React.useEffect(() => {
fetchData();
}, []);
const fetchData = async () => {
setIsLoading(true);
await api
.getData()
.then(data => {
setData(data);
})
.catch(error => {
alert(error.message);
})
.finally(() => setIsLoading(false));
};
return (
<>
{isLoading && <span>Loading...</span>}
{data && <Heatmap data={data} />}
</>
);
};
- Clone this repo:
git clone [email protected]:marcelovicentegc/react-github-heatmap.git
- Install dependencies:
yarn
- Build the app:
yarn build
- Change directory into
example
and install its dependencies:cd example && yarn
- From inside the
example
folder, start the app:yarn start