Thank you for your components
But I want to show you the names of both parties.What should I do?
Just inherit from Bubble and render customised bubble component with name in renderBubble prop of
Is there a way to show the name only on the first bubble of a sequence of bubbles of the same user?
for those we still need any help, you could do something like below.
import { GiftedChat, Bubble } from 'react-native-gifted-chat'
renderName = (props) => {
const { user: self } = this.state
const { user = {} } = props.currentMessage
const { user: pUser = {} } = props.previousMessage
const isSameUser = pUser._id === user._id
const isSelf = user._id === self._id
const shouldNotRenderName = isSameUser
return shouldNotRenderName ? (
<View />
) : (
<Text
style={[ isSelf ? styles.selfUser : styles.otherUser ]}>
{user.name}
</Text>
)
}
renderBubble = (props) => {
return (
<View>
{this.renderName(props)}
<Bubble {...props} />
</View>
)
}
}
render () {
return (
<GiftedChat
renderBubble={this.renderBubble}
/>
)
}
Most helpful comment
for those we still need any help, you could do something like below.