Fragment標籤
在佈局時,有事會看到<Fragment>
標籤,這個標籤有什麼用呢?
React.Fragment
官方文檔:
React 中一個常見模式是爲一個組件返回多個元素。Fragments 可以讓你聚合一個子元素列表,並且不在DOM中增加額外節點。
Fragments 看起來像空的 JSX 標籤,即:
const comp = ()=>{
return (
<>
<td>abc</td>
<td>dec</td>
</>
)
}
上面的<>
其實就等同於<Fragment>
,<>
是一個語法糖
Helmet標籤
react在做基本佈局時,也會用上。有時,需要動態修改頁面的<head>
中的標籤,如修改標題<title>
、<link>
<meta>
等時,可以用這個實現
用法如下
import {Helmet} from "react-helmet";
const comp = ()=>{
return (<>
<Helmet>
<title>這是頁面的標題</title>
</Helmet>
</>)
}