0

I have recently integrated stream-chat-react-native in my react-native project and I have integrated it successfully means I am able to create channel and connect user but whenever I am trying to send message through it , it throws error: Possible Unhandled Promise Rejection (id: 1): TypeError: undefined is not an object (evaluating 'updated_at.toISOString')

below is my code for chat room

import { StyleSheet, Text, View } from 'react-native'
import React, { useEffect, useState } from 'react'
import { useStoreState } from 'easy-peasy'
import AsyncStorage from '@react-native-async-storage/async-storage'
import { StreamChat } from 'stream-chat';
import { Channel, ChannelList, Chat, MessageInput, MessageList, OverlayProvider } from 'stream-chat-react-native';

const Chatroom = () => {
    const { user } = useStoreState(state => state.user.me)
    const client = StreamChat.getInstance('pcxtzykgg879');

    const [channel, setChannel] = useState();

    useEffect(()=>{
        const connectUser = async() => {
            // const userInfo = JSON.parse(await AsyncStorage.getItem('user'))
            if(!user){
              return
            }
        
            await client.connectUser(
              {
                id: JSON.stringify(user.profileable.id),
                name: user.full_name,
                image: 'https://i.imgur.com/fR9Jz14.png',
              },
              client.devToken(JSON.stringify(user.profileable.id)),
            );

            const channel = client.channel('messaging', 'the_park', {
                name: 'The Park',
              });
              await channel.create();
          }
        connectUser()
    },[])

    useEffect(()=>{
        if(client){
            return () => {
                client.disconnectUser()
            }
        }
    },[])
  return (
    <View style={{flex:1}}>
      {channel ? (
          <Channel channel={channel}>
            <MessageList />
            <MessageInput/> 
          </Channel>
        ) : (
          <ChannelList onSelect={setChannel} />
        )}
    </View>
  )
}

export default Chatroom

const styles = StyleSheet.create({})

below is my package.json dependencies

"dependencies": {
    "@georstat/react-native-image-cache": "1.6.0",
    "@klarna/react-native-vector-drawable": "^0.3.0",
    "@react-native-async-storage/async-storage": "1.17.7",
    "@react-native-clipboard/clipboard": "^1.10.0",
    "@react-native-community/blur": "^4.3.2",
    "@react-native-community/cameraroll": "^4.1.2",
    "@react-native-community/cli": "^4.8.0",
    "@react-native-community/datetimepicker": "^3.5.2",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/netinfo": "^5.9.10",
    "@react-native-community/progress-bar-android": "^1.0.4",
    "@react-native-community/progress-view": "^1.2.3",
    "@react-native-community/push-notification-ios": "^1.9.0",
    "@react-native-community/toolbar-android": "^0.1.0-rc.2",
    "@react-native-firebase/app": "^12.7.2",
    "@react-native-firebase/messaging": "^12.7.2",
    "@react-navigation/drawer": "^5.5.0",
    "@react-navigation/material-bottom-tabs": "^5.1.9",
    "@react-navigation/native": "^5.1.6",
    "@react-navigation/stack": "^5.2.13",
    "@stream-io/flat-list-mvcp": "^0.10.3",
    "apisauce": "^1.1.1",
    "aws-sdk": "^2.741.0",
    "easy-peasy": "^5.0.3",
    "expo": "~38.0.8",
    "expo-splash-screen": "^0.5.0",
    "expo-status-bar": "^1.0.2",
    "expo-updates": "~0.2.10",
    "html-parse-stringify": "^2.0.0",
    "i18n-js": "^3.5.1",
    "lodash": "^4.17.15",
    "lottie-ios": "3.1.8",
    "lottie-react-native": "4.0.2",
    "moment": "^2.27.0",
    "moment-timezone": "^0.5.31",
    "native-base": "^2.13.13",
    "patch-package": "^6.2.2",
    "postinstall-postinstall": "^2.1.0",
    "prop-types": "^15.7.2",
    "react": "~16.11.0",
    "react-dom": "~16.11.0",
    "react-native": "~0.62.3",
    "react-native-animatable": "^1.3.3",
    "react-native-base64": "^0.2.1",
    "react-native-calendars": "^1.1297.0",
    "react-native-camera": "^4.2.1",
    "react-native-circular-progress": "^1.3.8",
    "react-native-document-picker": "^3.5.4",
    "react-native-draggable-flatlist": "^3.1.2",
    "react-native-draggable-grid": "^2.1.6",
    "react-native-element-dropdown": "^2.9.0",
    "react-native-elements": "^2.0.4",
    "react-native-fast-image": "^8.6.3",
    "react-native-file-access": "1.7.1",
    "react-native-fs": "^2.20.0",
    "react-native-geolocation-service": "^5.3.0-beta.4",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-google-places-autocomplete": "^2.4.1",
    "react-native-haptic-feedback": "^2.0.3",
    "react-native-image-crop-picker": "^0.38.1",
    "react-native-image-picker": "2.3.4",
    "react-native-image-resizer": "^1.4.5",
    "react-native-in-app-review": "^4.1.1",
    "react-native-inappbrowser-reborn": "^3.7.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-keychain": "4.0.1",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-maps": "0.31.1",
    "react-native-modal": "^11.5.6",
    "react-native-modal-datetime-picker": "^10.0.0",
    "react-native-modalize": "^2.0.13",
    "react-native-nfc-manager": "^3.14.3",
    "react-native-paper": "^4.11.2",
    "react-native-permissions": "^3.3.1",
    "react-native-portalize": "^1.0.7",
    "react-native-push-notification": "^8.0.0",
    "react-native-reanimated": "^2.2.0",
    "react-native-render-html": "^6.3.1",
    "react-native-safe-area-context": "~3.0.7",
    "react-native-screens": "^2.7.0",
    "react-native-share": "^9.0.2",
    "react-native-signature-canvas": "^4.3.0",
    "react-native-sound": "^0.11.2",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^9.13.6",
    "react-native-tiny-toast": "^1.0.7",
    "react-native-toast-message": "^1.4.9",
    "react-native-unimodules": "~0.10.1",
    "react-native-uuid": "^2.0.1",
    "react-native-vector-icons": "^8.1.0",
    "react-native-vector-image": "^0.3.2",
    "react-native-web": "~0.11.7",
    "react-native-webview": "^11.14.3",
    "redux-logger": "^3.0.6",
    "rn-fetch-blob": "^0.12.0",
    "stream-chat": "^8.9.0",
    "stream-chat-react-native": "^3.0.0"
  },

I haven't got that 'updated_at.toISOString' in node modules or anywhere so I am not able to resolve itenter image description here

Kaustubh
  • 1
  • 2

0 Answers0