Commit 05750bb2 authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复组件销毁还更新state的问题

parent 9dd0f331
...@@ -75,7 +75,7 @@ const AnchorPage = (props: IProps) => { ...@@ -75,7 +75,7 @@ const AnchorPage = (props: IProps) => {
useEffect(() => { useEffect(() => {
const firstKey = anchors.length ? `#${anchors[0].key}` : ''; const firstKey = anchors.length ? `#${anchors[0].key}` : '';
if (firstKey && firstKey !== current) { if (firstKey && firstKey !== current) {
setCurrent(firstKey); mounted.current && setCurrent(firstKey);
} }
}, [anchors]); }, [anchors]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment