Я пытаюсь сделать условный нижний колонтитул состояния для одаренного чата React Native. Я создал состояние логической переменной 'userReply' для конструкции, а затем прикрепил пользовательское представление к представлению нижнего колонтитула Gifted-Chat, как показано ниже:
constructor(props) {
super(props);
this.onLongPress = this.onLongPress.bind(this);
this.renderFooterReply = this.renderFooterReply.bind(this);
this.state = {
messages: [],
userReply: false
};
}
И вот как я обновляю состояние при длинном щелчке по элементу;
onLongPress(ctx, currentMessage) {
this.state.currentMessage = currentMessage;
const options = [
'Reply',
'Copy Text',
'Cancel',
];
const cancelButtonIndex = options.length - 1;
ctx.actionSheet().showActionSheetWithOptions({
options,
cancelButtonIndex,
},
(buttonIndex) => {
switch (buttonIndex) {
case 0:
this.setState({userReply: true});
break;
case 1:
Clipboard.setString(currentMessage.text);
break;
}
});
}
И после того, как я нажал кнопку Ответить, это представление должно быть визуализировано;
renderFooterReply() {
alert(this.state.userReply);
if (this.state.userReply) {
return (
<View style={{height: 50, flexDirection: 'row'}}>
...
</View>
);
}
return null;
}
Наконец, как я настраиваю настраиваемое представление для нижнего колонтитула одаренного чата;
render() {
return (
<GiftedChat
messages={this.state.messages}
onSend={messages => this.onSend(messages)}
onLongPress={(ctx, currentMessage) => this.onLongPress(ctx, currentMessage)}
renderFooter={this.renderFooterReply}
user={{
_id: 1,
}}
/>
)
}
Но когдаСостояние userReply изменилось, нижний колонтитул не рендерится. Любой совет? Спасибо.