useLocation 与useMemo,相互组合的函数需要:
不然获取的URL
是useMemo
里面的缓存
location 无法获取最新URL
import React, { useState, useEffect, useRef, useMemo } from 'react';
import { withRouter, useLocation } from 'react-router-dom';
const location = useLocation();
const headerBtn = useMemo(() => {
}, [location ]);