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