Экран GiftedChat не виден при интеграции с существующим проектом - PullRequest
1 голос
/ 06 марта 2020

Я новичок, чтобы реагировать на родной язык, и я работаю над добавлением функции чата в мое приложение. Для обучения я следовал учебному пособию и создал отдельное приложение для чата, и оно работало отлично. standalone chat app Но когда я попытался интегрировать его с остальной частью моего проекта - все, что я получил, было пустым экраном when integrating with the rest of my app Я проверил одаренные версии чата в обеих - это тот же ^ 0.13.0 и я проверил код чата в обоих - это точно так же. Я не понимаю, почему ничего не видно и как я могу это исправить? Помощь будет по достоинству оценена! Помещение пакета . json, а также в случае проблемы с версией

Автономный чат

import React, {Component} from 'react';
import { GiftedChat } from 'react-native-gifted-chat';
import { db } from 'C:/Users/Suman Shaw/testCareApp/config';

let saveMessage = message => {
  db.ref('/messages').push({
    messageText: message
  });
};  

export default class giftedChat extends React.Component {
  state = {
    messages: [],
  }

  componentDidMount() {
    this.setState({
      messages: [
        {
          _id: 1,
          text: 'Hi There !',
          createdAt: new Date(),
          user: {
            _id: 2,
            name: 'suman@gmail.com',
            avatar: 'https://placeimg.com/640/480/nature',
          },
        },
      ],
    })
  }

  onSend(messages = []) {
    this.setState(previousState => ({
      messages: GiftedChat.append(previousState.messages, messages),
    }))
    db.ref('/messages').push({ messages });
  }

  render() {
    return (
      <GiftedChat
        messages={this.state.messages}
        onSend={messages => this.onSend(messages)}
        user={{
          _id: 1,
        }}
      />
    )
  }
}

. json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "~36.0.0",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
    "react-native-gifted-chat": "^0.13.0",
    "react-native-web": "~0.11.7"
  },
  "devDependencies": {
    "babel-preset-expo": "~8.0.0",
    "@babel/core": "^7.0.0"
  },
  "private": true
}

В моем приложении:

class ChatPage extends React.Component {

  render() {
  return (
    <View style={styles.container}>
        <Button title="Chat room" color='#00bcd4' onPress={() => this.props.navigation.navigate('giftedChat')} /> //the same file copied from the standalone chat
    </View>
  );
}
const RootStack = createStackNavigator(
  {
    WelcomePage: WelcomePage,
    giftedChat : giftedChat, 

  }
);

export default createAppContainer(RootStack);

пакет. json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@react-native-community/masked-view": "0.1.5",
    "@react-native-firebase/auth": "^6.3.4",
    "@react-navigation/native": "^5.0.7",
    "@react-navigation/stack": "^5.0.8",
    "expo": "~36.0.0",
    "firebase": "^7.9.3",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
    "react-native-dotenv": "^0.2.0",
    "react-native-gesture-handler": "^1.6.0",
    "react-native-gifted-chat": "^0.13.0",
    "react-native-reanimated": "~1.4.0",
    "react-native-router-flux": "^4.2.0",
    "react-native-safe-area-context": "0.6.0",
    "react-native-screens": "2.0.0-alpha.12",
    "react-native-web": "~0.11.7"
  },
  "devDependencies": {
    "@babel/core": "^7.0.0",
    "babel-preset-expo": "~8.0.0",
    "expo-cli": "^3.13.1"
  },
  "private": true
}

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...