|
|
@@ -26,15 +26,15 @@ const CategorySidebarItem: React.FC<CategorySidebarItemProps> = (props) => {
|
|
|
const context = useContext(CategorySidebarContext);
|
|
|
const itemRef = React.useRef<any>(null);
|
|
|
|
|
|
- // // 注册到父组件
|
|
|
- // useEffect(() => {
|
|
|
- // if (context) {
|
|
|
- // context.registerItem(itemRef.current);
|
|
|
- // return () => {
|
|
|
- // context.unregisterItem(itemRef.current);
|
|
|
- // };
|
|
|
- // }
|
|
|
- // }, [context]);
|
|
|
+ // 注册到父组件
|
|
|
+ useEffect(() => {
|
|
|
+ if (context) {
|
|
|
+ context.registerItem(itemRef.current);
|
|
|
+ return () => {
|
|
|
+ context.unregisterItem(itemRef.current);
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }, [context]);
|
|
|
|
|
|
// 设置选中状态
|
|
|
const setActive = useCallback((isActive: boolean) => {
|