Я хочу иметь заголовок, который может настраивать просмотр в зависимости от того, на каком экране он вызван. Поэтому мне нужно передать компонент в качестве аргумента моему компоненту заголовка. Но, похоже, это не работает.
Вот мой пользовательский компонент
...
const ComponentRight = () => {
return (
<Right>
<Button transparent onPress= {() => {
{enablePinned ?
addChatPinned(chatSelected) :
removeChatPinned(chatSelected)
}
}}>
{enablePinned ?
<Icon type= 'MaterialCommunityIcons' name= 'pin'/> :
<Icon type= 'MaterialCommunityIcons' name= 'pin-off'/>
}
</Button>
<Button
transparent
onPress= {() => deleteChatList(chatSelected)}>
<Icon type= 'FontAwesome5' name= 'trash' style= {{fontSize: 20}}/>
</Button>
<Button transparent>
<Icon type= 'MaterialIcons' name= 'archive' style= {{fontSize: 25}}/>
</Button>
</Right>
)
}
return (
<Container>
{showAction ?
<SelectHeader
onBack= {resetChatSelected()}
itemCount= {chatSelected.length}
componentRight= {ComponentRight}/> // passing my component as argument
...
И этот мой компонент заголовка
const SelectHeader = ({onBack, itemCount, componentRight}) => {
return (
<Header style= {appStyles.headerBackgroundColor}>
<Left style= {{flexDirection: 'row'}}>
<Button
transparent
style= {{marginRight: 30}}
onPress= {() => {onBack}}>
<Icon type='Ionicons' name= 'md-arrow-back' style= {{fontSize: 25}} color= 'white'/>
</Button>
<Title style= {appStyles.appTitle, {alignSelf: 'center'}}>{itemCount}</Title>
</Left>
<Body/>
{componentRight}
</Header>
)
}
export default SelectHeader
Кто-нибудь знает, как это сделать sh ? спасибо