import React from 'react'; import { ConnectProps } from '@/common/types'; import { pathToRegexp } from 'path-to-regexp'; // 该wrapper的作用是可以使得组件既充当page又充当一个container const Diverse: React.FC = props => { const { location, children, route } = props; const justRenderChildren = route && location && !pathToRegexp(route.path).test(location.pathname); // eslint-disable-next-line return !justRenderChildren ? ( <>{children} ) : ( <>{children?.props?.children} ); }; export default Diverse;