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.

Nothing is rendered

See original GitHub issue

Issue Description

I’m getting a blank screen when running the example.

Steps to Reproduce / Code Snippets

Slightly modify the example here: https://github.com/FaridSafi/react-native-gifted-chat#example and use it in the default React Native blank template.

// App.js
import React from 'react';
import {SafeAreaView, StyleSheet, ScrollView, StatusBar} from 'react-native';

import {Colors} from 'react-native/Libraries/NewAppScreen';

import Chat from './src/Chat';

const App: () => React$Node = () => {
  return (
    <>
      <StatusBar barStyle="dark-content" />
      <SafeAreaView>
        <ScrollView
          contentContainerStyle={{
            flexDirection: 'row',
          }}
          contentInsetAdjustmentBehavior="automatic"
          style={styles.scrollView}>
          <Chat />
        </ScrollView>
      </SafeAreaView>
    </>
  );
};

const styles = StyleSheet.create({
  scrollView: {
    backgroundColor: Colors.lighter,
  },
});

export default App;
// src/Chat.js
import React, {useState, useCallback, useEffect} from 'react';
import {GiftedChat} from 'react-native-gifted-chat';

const Chat = () => {
	const [messages, setMessages] = useState([]);

	useEffect(() => {
		setMessages([
			{
				_id: 1,
				text: 'Hello developer',
				createdAt: new Date(),
				user: {
					_id: 1,
					name: 'React Native',
					avatar: 'https://placeimg.com/140/140/any',
				},
			},
			{
				_id: 2,
				text: 'Hellos developer',
				createdAt: new Date(),
				user: {
					_id: 1,
					name: 'dd',
					avatar: 'https://placeimg.com/140/140/any',
				},
			},
		]);
	}, []);

	const onSend = useCallback((messages = []) => {
		setMessages((previousMessages) =>
			GiftedChat.append(previousMessages, messages),
		);
	}, []);

	return (
		<GiftedChat
			messages={messages}
			onSend={(messages) => onSend(messages)}
			user={{
				_id: 1,
			}}
		/>
	);
};

export default Chat;

Expected Results

Chat UI is rendered.

Additional Information

  • Nodejs version: 14.4.0
  • React version: 16.13.1
  • React Native version: 0.63.4
  • react-native-gifted-chat version: 0.16.3
  • Platform(s) (iOS, Android, or both?): only tested on iOS
  • TypeScript version: N/A

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14

github_iconTop GitHub Comments

3reactions
oxbitscommented, Mar 6, 2021

my issue was something else

for the vanilla gifted chat i just created a new blank react native app and replaced the hello world at App.js with gifted-chat example code from the readme this proved it worked on both devices

then i realized it had nothing to do with gifted chat it was unexpected data from an API call that the react native client code was choking on and crashing

sorry if this is not more helpful

have you tried rolling back to an earlier version ?

3reactions
oxbitscommented, Mar 1, 2021

in my app it renders on my iPhone 6s 14.4

on my friend’s iPhone XR it is blank

so i built a vanilla gifted chat app and that appears on both devices

Read more comments on GitHub >

github_iconTop Results From Across the Web

React not rendering anything on the DOM - Stack Overflow
I have just started learning ReactJS and made my first app by following a tutorial but nothing is rendered on the screen when...
Read more >
REACT - Simple Intro component not rendering? - JavaScript
Hey I've been trying React, total newbie but this component mainIntro.js is not getting imported into the main react component App.js.
Read more >
Nothing Rendering on Web Page · Issue #111 · reactjs/react ...
The problem is that nothing shows up on a web page, there are no errors related to the input of data into the...
Read more >
Nothing was returned from render Error in React [Solved]
The "Nothing was returned from render" React error occurs when we forget to explicitly return a value from a function or class component....
Read more >
"Nothing was returned from render." ReactJS Error - Owen Conti
Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.
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