关于“function Home(): JSX.Element {”的写法
来源:5-2 FileSearch 组件(一)

慕慕0439991
2020-07-17
张老师,您好,我在您的课程中看到,组件是这样写的,
然后我看到electron-react-boilerplate中的组件是这样写的,
请问一下,我把这个改成这样可以吗?
export default function FileSearch({ title, onFileSearch }): JSX.Element {
return (
<div className="App container-fluid">
<div className="row">
<div className="col-3 bg-light left-panel">
<h1>this is the left</h1>
</div>
<div className="col-9 bg-primary right-panel">
<h1>this is the right</h1>
</div>
</div>
</div>
);
}
期待您的回复!
写回答
1回答
-
张轩
2020-07-17
同学你好 这是 typescript 的写法,使用这种写法之前强烈推荐你学习一下 typescript,搞清楚来龙去脉,你的写法是没问题的,这个其实指示了 函数 的返回,返回的类型是一个 JSX.element ,关于 typescript,我有门课卖的挺好,https://coding.imooc.com/class/428.html 如果有需要你可以看看。
112020-07-17
相似问题