1 回答

TA貢獻1848條經驗 獲得超10個贊
看起來我忘記了這個布局及其更改為功能版本的一個重要方面!
除了處理由于瀏覽器寬度變化而導致的組件不同布局之外,我忘記在功能鉤子中添加其他重要的依賴項useEffect(漢堡包側面板、模式功能等)。特別是fixed, children, isToggled, modalActive。
當我繼續引用prop/state它所依賴的那些值的類版本時,功能組件的外觀和感覺自然會比原始版本(類版本)有所改進。
這是僅使用鉤子 \o/ 的新更新版本
import React, { useCallback, useState, useEffect, useContext } from 'react';
import { Link, NavLink } from 'react-router-dom';
import Modal from '../components/Modal/MyModal.jsx';
import {
Container,
Menu,
Responsive,
Segment,
Visibility,
Sidebar,
Icon,
Button
} from 'semantic-ui-react';
import { connect } from 'react-redux';
import { modalStateOn, modalStateOff } from '../store/reducers/ui/index';
import UserContext from '../components/UserContext/UserContext.jsx';
const getWidth = () => {
const isSSR = typeof window === 'undefined';
return isSSR ? Responsive.onlyTablet.minWidth : window.innerWidth;
};
function logOutMenuItemHelper(
isMobile,
isLoggedIn,
history,
modalActive,
nav,
NavLink,
modalStateOn,
modalStateOff,
handleSidebarHide
添加回答
舉報