好吧,我得到了部件採用進口爲存儲組件到一個變量,然後重新使用
import Payment from './pages/payment';
import Chat from './pages/chat';
現在我使用Drawer
組件,並與Navigator
一起使用它我renderScene變得像這樣
if(route.id == 'payment'){
return <Drawer xx={} yy={} and a lot more >
<Payment navigator={navigator} />
</Drawer>
}
if(route.id == 'chat'){
return <Drawer xx={} yy={} and a lot more >
<Chat navigator={navigator} />
</Drawer>
}
那些冗長的Drawer
代碼被一次又一次地使用。我想將<Payment navigator={navigator} >
或另一個存儲到一個變量中,然後將其僅返回Drawer
一次。
我如何存儲它並將其與抽屜一起返回?
感謝
謝謝您。我其實曾經嘗試過非常類似於此,但是使用'var'而不是'const',它給了我錯誤。更改爲'const',它工作:) – cjmling