question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to display no messages found if messages object is empty.

See original GitHub issue

I was trying to render a view to display ‘No messages found’ if the messages object is empty. for this which function i need to use. Currently I tried using renderMessage but got error. i just want to figure it out how this can be achieved

My code is

               <GiftedChat
                    composerHeight={COMPOSER_HEIGHT}
                    minInputToolbarHeight={COMPOSER_HEIGHT}
                    messages={this.state.messages}
                    onSend={messages => this.onSend(messages)}
                    user={{ _id: this.state.senderUserName }}
                    loadEarlier={this.state.loadEarlier}
                    isLoadingEarlier={this.state.isLoadingEarlier}
                    onLoadEarlier={this.onLoadEarlier}
                    placeholder="Type your message"
                    renderSend={this.renderSend}
                    alwaysShowSend={true}
                    renderActions={this.imageSend.bind(this)}
                    renderInputToolbar={this.renderInputToolbar}
                    renderBubble={this.renderBubble.bind(this)}
                    renderMessage={this.renderMessage.bind(this)}
                    renderMessageImage={this.renderMessageImage}
                    renderAvatar={null}
                    inverted={true}
                />

In render message my code is :

renderMessage(props) {
  if(this.state.messages.length !==0){
       return <Message {...props} />;
 } else {
  return <View style={{flex:1, backgroundColor:'red'}}>
    <Text>Hello no data found</Text>
  </View>
}
return null
}

I know i’m doing wrong. But i can’t be able to find correct result. any suggestions?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
saikiranoptisolcommented, Feb 5, 2019

for every question i was asking here you are mentioning to check in stackoverflow. But after checking in stackoverflow only i have posted here this. and yes i do have posted the same in stackoverflow as well https://stackoverflow.com/q/54529508/10966893 . please provide proper solution that will do needful for me

0reactions
hadpro24commented, May 25, 2020

@xcarpentier

Did you try it: https://stackoverflow.com/a/54550286/1458375

But it’s not display a InputText if they used message.length == 0

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to display a message if the array of objects is empty ...
i want to display a message if the object contains data or not. Currently i store the data in state named "data" and...
Read more >
Video: Input and error messages - Microsoft Support
On the Input Message tab, check the box next to Show input message when cell is selected. Type a Title if you want....
Read more >
Throw error and display message - MATLAB error - MathWorks
This MATLAB function throws an error and displays an error message.
Read more >
Discord Developer Portal — Documentation — Channel
You can tell if a message is generated by a webhook by checking for the webhook_id on the message object. ** An app...
Read more >
Validation - Laravel - The PHP Framework For Web Artisans
Validating Nested Array Input; Error Message Indexes & Positions ... If no old input exists for the given field, null will be returned:....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found