1 回答

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超10個(gè)贊
看起來我忘記了這個(gè)布局及其更改為功能版本的一個(gè)重要方面!
除了處理由于瀏覽器寬度變化而導(dǎo)致的組件不同布局之外,我忘記在功能鉤子中添加其他重要的依賴項(xiàng)useEffect(漢堡包側(cè)面板、模式功能等)。特別是fixed, children, isToggled, modalActive。
當(dāng)我繼續(xù)引用prop/state它所依賴的那些值的類版本時(shí),功能組件的外觀和感覺自然會(huì)比原始版本(類版本)有所改進(jìn)。
這是僅使用鉤子 \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
添加回答
舉報(bào)