私は反応してネイティブに反応します。私は、反応したネイティブのための図書館を使いたい。 https://github.com/FaridSafi/react-native-gifted-chat しかし、私はこのエラーを得た:React.createElement:タイプが無効です
警告:React.createElement:タイプが無効です - 予想(内蔵部品のための)文字列 か(複合 コンポーネントの)クラス/関数ではなくなりました:オブジェクト。 コンポーネントを定義したファイルからエクスポートするのを忘れた可能性があります。
registerRootComponent.js:21でコードを確認してください。 RCTViewで (View.js時:128)(93 AppContainer.jsで) ビューで:RCTViewで (128 View.jsで):(35 renderApplication.jsで)ExponentRootComponentで ビューで(AppContainerで.js:renderApplication.jsでAppContainer 92) (:34)
ここに私のコード:
yarn add react-native-gifted-chat
:
import React from 'react';
import { StyleSheet, Text, View, KeyboardAvoidingView, Image, TextInput } from 'react-native';
import GiftedChat from 'react-native-gifted-chat';
class App extends React.Component {
state = {
messages: [],
};
componentWillMount() {
this.setState({
messages: [
{
_id: 1,
text: 'Hello developer',
createdAt: new Date(),
user: {
_id: 2,
name: 'React Native',
avatar: 'https://facebook.github.io/react/img/logo_og.png',
},
},
],
});
}
onSend(messages = []) {
this.setState((previousState) => ({
messages: GiftedChat.append(previousState.messages, messages),
}));
}
render() {
return (
<GiftedChat
messages={this.state.messages}
onSend={(messages) => this.onSend(messages)}
user={{
_id: 1,
}}
/>
);
}
}
私はこのlibを追加します
私はAndroidのエミュレータで私のアプリを起動するためにExpo-XDEを使用します。
で輸出を追加doesntのwork – Xero
あなたは 'App'コンポーネントをエクスポートしていますよね? –
申し訳ありませんが、もう一度クラッシュしてしまいました...この「デフォルトのアプリをエクスポート」を追加しました。トップに戻る – Xero