xref: /MusicFree/src/pages/topList/components/boardPanelWrapper.tsx (revision 2aa881935ca35b8fb1abc4206e0dc35149231456)
1import React, {useEffect, useMemo} from 'react';
2import useGetTopList from '../hooks/useGetTopList';
3import {useAtomValue} from 'jotai';
4import {pluginsTopListAtom} from '../store/atoms';
5import BoardPanel from './boardPanel';
6
7interface IBoardPanelProps {
8    hash: string;
9}
10export default function BoardPanelWrapper(props: IBoardPanelProps) {
11    const {hash} = props ?? {};
12    const topLists = useAtomValue(pluginsTopListAtom);
13    const getTopList = useGetTopList();
14    const topListData = useMemo(() => topLists[hash], [topLists]);
15
16    useEffect(() => {
17        getTopList(hash);
18    }, []);
19
20    return <BoardPanel topListData={topListData} hash={hash} />;
21}
22