我最近了解到您可以制作這樣的自定義組件:
const CustomComp=()=>{
console.log('Created custom comp');
return(<View></View>);
}
export default function App(){
return(<View style={{flex:1}}>
<CustomComp />
</View>)
}
但是有可能用速記來做嗎?
export default function App(){
return(<View style={{flex:1}}>
<(()=>{
console.log('Created custom comp');
return(<View></View>);
}) />
</View>)
}
這不準確,但我想你對我的查詢有了大致的了解
uj5u.com熱心網友回復:
您可以使用 IIFE 就地評估函式:
export default function App(){
return(<View style={{flex:1}}>
{(() => {
console.log('Created custom comp');
return(<View></View>);
})()}
</View>)
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/330754.html
標籤:javascript 反应 反应原生
