import {map} from 'nanostores'
let allData = map({})
export const currentData = map({})
export function setCurrentData(cluster) {
currentData.set(allData.get[cluster])
}
export async function fetchYearData(year) {
const response = await fetch(`https://harikar-reports-api.cyclic.app/v2/dashboard/${year}`)
if (!response.ok) {
console.log(response.statues)
} else {
const data = await response.json()
allData.set(data)
setCurrentData('general')
}
}
my store ^
import { useStore } from "@nanostores/preact";
import { currentData } from "src/stores/store";
const DistrictsChart = () => {
const $currentData = useStore(currentData);
line four of the second codeBlock is where the error happening.
I am calling the fetchYearData(year) in a useEffect in another preact component
useEffect(() => {
fetchYearData(props.year);
}, []);
the component with the useEffect is using client:load, and the one with useStore is client:only="preact"