React-native-gifted-chat: Is there any way I can add a header bar

Created on 12 Jul 2017  路  4Comments  路  Source: FaridSafi/react-native-gifted-chat

Issue Description

I'm looking to add a header bar with a summary of the chat content and a back button, my attempts have not gone well, any help would be appreciated.

Additional Information

  • React Native version: 2.0.1
  • react-native-gifted-chat version: ^0.1.4
  • Platform(s) (iOS, Android, or both?): iOS

Most helpful comment

@smccamley @varungupta85
Just a heads up to anybody in the future:
When you wrap these components in a View set the flex to 1. The view you are giving it has no size and therefore the child components are inheriting their size from the parent (which is 0).

(Otherwise Gifted chat will disappear after adding the header component)(https://github.com/FaridSafi/react-native-gifted-chat/issues/613)

This worked for me:

<View style={{flex: 1}}>
        <Header {props...} />
        <GiftedChat {props...} />
</View>

see: https://stackoverflow.com/a/43197064

All 4 comments

You can compose a new component in your app using a ChatHeaderBar and GiftedChat components. The ChatHeaderBar component is something that you will write separately for your app and not part of GiftedChat. So, the resulting component would render something like:

<View>
  <ChatHeaderBar {someProps} />
  <GiftedChat {someProps} />
</View>

Thank you, I'm a little new to react-native. I had tried that, but it wasn't working. Tried again just now and works perfectly. No idea what I was doing wrong.
馃憤

Let's close this, if it's no longer a problem.

@smccamley @varungupta85
Just a heads up to anybody in the future:
When you wrap these components in a View set the flex to 1. The view you are giving it has no size and therefore the child components are inheriting their size from the parent (which is 0).

(Otherwise Gifted chat will disappear after adding the header component)(https://github.com/FaridSafi/react-native-gifted-chat/issues/613)

This worked for me:

<View style={{flex: 1}}>
        <Header {props...} />
        <GiftedChat {props...} />
</View>

see: https://stackoverflow.com/a/43197064

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arayaryoma picture arayaryoma  路  3Comments

maharjanaman picture maharjanaman  路  3Comments

radvc picture radvc  路  3Comments

jasonwcfan picture jasonwcfan  路  3Comments

inceptivetech picture inceptivetech  路  3Comments