【发布时间】:2021-05-09 04:26:38
【问题描述】:
这是我的代码
function Label({title}){
return <h1>{title}</h1>
}
function useLabel({title}){
return <h1> {title}</h1>
}
function Diff(){
return <div>
<Label title='this is component'/>
{useLabel({title:'this is custom hook'})}
</div>
}
在代码中,我定义了组件Label和自定义钩子useLabel。除了使用不同的语法调用之外,它们执行完全相同的工作。
我的问题是:
- 除了调用语法,自定义和自定义有什么区别 钩子和组件?
- 我可以一直使用自定义挂钩而不是 组件?
【问题讨论】:
标签: reactjs react-hooks