我有此代码:
import { Route } from 'react-router'
const layoutPropTypes = {
component: pt.any,
path: pt.string.isRequired,
exact: pt.bool,
}
const DashboardLayoutRoute = ({
component: Component,
...rest
}: InferProps<typeof layoutPropTypes>) => {
const render = (matchProps: any) => (
<DashboardLayout>
<Component {...matchProps} />
</DashboardLayout>
);
return (<Route {...rest} render={render} />);
};
但是TypeScript确实不喜欢我将...rest
的道具传递到Route:
如果删除{...rest}
部分,没有任何问题。怎么了我不太了解null
的来源。