【发布时间】:2021-10-19 15:44:12
【问题描述】:
我正在尝试使用天才聊天中的 renderAction 道具制作自定义菜单以共享图片和位置。我无法让它调用函数。 renderActions={console.log('hello')} 按预期输出,由于某些原因没有调用函数。
我查看了代码示例,但找不到任何我遗漏的东西 - 但显然我遗漏了一些东西。
这是代码。如果有任何额外的信息会有所帮助,请告诉我,我会添加它。仍然是新的堆栈。
renderActions > console.log() 没有被调用
renderActions() {
console.log('renderActions called');
}
renderAction={console.log()} 被调用。 renderActions={this.renderActions} 不会被调用。 我试过以我能想到的各种方式传递它: {() = > this.renderActions()}, {this.renderActions.bind(this)}, {this.renderActions} ...似乎没有任何效果。
render() {
let bgColor = this.props.route.params.bgColor;
return (
<View style={[styles.bodyContent]}>
<GiftedChat
renderBubble={this.renderBubble.bind(this)}
renderSystemMessage={this.renderSystemMessage.bind(this)}
renderInputToolbar={this.renderInputToolbar.bind(this)}
renderActions={() => this.renderActions()}
messages={this.state.messages}
onSend={(messages) => this.addMessage(messages)}
user={{
_id: this.state.uid,
}}
/>
{Platform.OS === 'android' ? (
<KeyboardAvoidingView behavior="height" />
) : null}
</View>
);
}
任何帮助将不胜感激。我确定我遗漏了一些明显的东西,但我完全被难住了。谢谢!
【问题讨论】:
标签: react-native react-native-gifted-chat