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