我有一个需要在路径名更改时更新的组件,但是我不知道如何访问location
函数内部的withRouter
附加的areEqual
确定是否应更新组件。
const myComponent = (props) => {}
const areEqual = (prevProps, nextProps) => {
return (
prevProps.location.pathname === nextProps.location.pathname // prints error
);
}
export default memo(withRouter(myComp), areEqual)