'Realm DB React native Schema - type must be of type 'string', got (undefined) Error

This is my Schema for a Message history i'm getting from the API

export default class MessageSchema {
  static schema = {
    name: 'MessagesHistory',
    primaryKey: '_id',
    properties: {
      _id: 'string',
      text: 'string',
      createdAt: 'string',
      user: {
        uname: 'string',
        name: 'string',
        _id: 'string',
        avatar: 'string',
        rid: 'string',
      },
    },
  };
}

and this is my Realm Function

import Realm from 'realm';

import ChatlistSchema from './ChatlistSchema';
import MessageSchema from './MessageSchema';

export default function getRealm() {
  return Realm.open({
    schema: [ChatlistSchema, MessageSchema],
  });
}

Whenever I try to add the MessagesSchema to the Schema array, it gives me a promise rejection, and the data from the ChatlistChema object isn't loading also.

*Error: type must be of type 'string', got (undefined)
[native code]*
............

Does anyone know what I'm doing wrong?



Solution 1:[1]

I had this error differently (got (0)) and the cause was there were some errors in a schema class. Some properties had a value 0 assigned instead of the data type name (double).

Solution 2:[2]

I had changed the schema sometime back (which I completely forgot) due to which I was facing this issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sandeepani
Solution 2 Ishwar Rimal