UNPKG

@proca/widget

Version:

Proca is an open-source campaign toolkit designed to empower activists and organisations in their digital advocacy efforts. It provides a flexible and customisable platform for creating and managing online petitions, email campaigns, and other forms of di

27 lines (20 loc) 708 B
import { useEffect, useState } from "react"; import { useCampaignConfig } from "@hooks/useConfig"; const Counter = () => { //const countries = new Set(); const [data, setData] = useState(null); const config = useCampaignConfig(); const url = `https://static.proca.app/ep2024/${config.campaign.name.replace("_citizen_", "_candidates_")}-count.json`; useEffect(() => { const fetchData = async url => { const res = await fetch(url); if (!res.ok) throw res.statusText; const d = await res.json(); setData(d.data.actionPage.campaign.stats.supporterCount); }; if (!url) return; fetchData(url); }, [url, setData]); return data; }; export default Counter;