无法使用{<item.element/>}的形式

来源:8-6 创建页面路由,制定接口规范(上)

Ho_gg

2023-06-03

老师,这里element我无法使用{<item.element/>},会提示Type ‘Element | (() => Element) | FC<{}>’ is not assignable to type ‘ReactNode’. Type ‘() => JSX.Element’ is not assignable to type ‘ReactNode’.ts(2322) components.d.ts(62, 5): The expected type comes from property ‘element’ which is declared here on type ‘IntrinsicAttributes & RouteProps’。如何解决?

写回答

3回答

weixin_慕田峪0594011

2023-12-15

import { Button, Result } from 'antd';import React from 'react';

const Page404: React.FC = () => (  <Result    status="404"    title="404"    subTitle="Sorry, the page you visited does not exist."    extra={<Button type="primary">Back Home</Button>}  />);export default Page404;


我也遇到同样的问题 加这个就可以了 React.FC

0
0

黑石

2023-06-03

需要贴一下你的代码,报错地方的代码。

0
0

Ho_gg

提问者

2023-06-03

应该是跟我含有Navigate的问题

0
0

React18+TS+NestJS+GraphQL 全栈开发在线教育平台

平台级应用+流行全栈技术+实用职场技巧&面试策略 助你升职加薪

439 学习 · 242 问题

查看课程