import { useState, useEffect } from "react"; import PaliChapterChannelList from "./PaliChapterChannelList"; import PaliChapterListByPara from "./PaliChapterListByPara"; import PaliChapterHead from "./PaliChapterHead"; import type { IChapterClickEvent } from "./PaliChapterList" import { Tabs } from "antd"; export interface IChapter { book: number; para: number; level?: number; } interface IWidget { chapter: IChapter; onChange?: Function; } const BookViewerWidget = ({ chapter, onChange }: IWidget) => { const [currChapter, setCurrChapter] = useState(chapter); useEffect(() => { if (typeof onChange !== "undefined") { onChange(currChapter); } }, [currChapter, onChange]); useEffect(() => { setCurrChapter(chapter); }, [chapter]); return ( <> { setCurrChapter(e); }} para={currChapter} /> { setCurrChapter({ book: e.para.Book, para: e.para.Paragraph }); console.log("PaliChapterListByPara", "onchange", e); }} /> ), }, { label: `资源`, key: "res", children: , }, ]} /> ); }; export default BookViewerWidget;