我需要写一些特别的东西,把我的组件包装成悬念,我会把组件和后备props 作为特别的props 来传递.
我的特别之处:
export const withSuspense = ({ Component, Fallback }: any)=> {
return (props:any) => {
return (
<Suspense fallback={<Fallback />}>
<Component {...props} />
</Suspense>
);
};
};
然后我需要在路径中渲染(Reaction-Router v6.15)
<Route
path="messages"
element={withSuspense({MessagesPage,Loader})}
/>
出现错误Type '(props: any) => JSX.Element' is not assignable to type 'ReactNode'.
我试图将即席props 定义为ReactNodes,但它不起作用.有什么好主意吗?