title: Undefined is not an object using react native realm
body: <p>I want to build an application using <code>react native</code> and implement <code>realm</code>. It is meant to have some playlists and songs, and the songs should be able to be added to the playlists.</p>
  
  <p><em>Playlist:</em></p>
  
  <pre><code>export class Playlist {
    public id: number;
    public name: string;
    public color: string;
    public songs: Song[];
    constructor(id: number, name: string, color: string, songs: Song[]) {
      this.id = id;
      this.name = name;
      this.color = color;
      this.songs = songs;
    }
  
    static schema: Realm.ObjectSchema = {
      name: 'Playlist',
      primaryKey: 'id',
      properties: {
        id: 'int',
        name: 'string',
        color: 'string',
        songs: 'Song[]',
      },
    };
  }
  </code></pre>
  
  <p><em>Song:</em></p>
  
  <pre><code>export class Song {
    public id: number;
    public title: string;
    public artist: string;
    constructor(id: number, title: string, artist: string) {
      this.id = id;
      this.title = title;
      this.artist = artist;
    }
  
    static schema: Realm.ObjectSchema = {
      name: 'Song',
      primaryKey: 'id',
      properties: {
        id: 'int',
        title: 'string',
        artist: 'string',
      },
    };
  }
  </code></pre>
  
  <p><em>Realm:</em></p>
  
  <pre><code>const initData = () =&gt; {
    const songs = [
      new Song(0, 'Avicii', 'Heaven'),
      // some songs
    ];
  
    const playlists = [
      new Playlist(0, 'Favorite Songs', 'purple', []),
      // some playlists
    ];
  
    songs.forEach(song =&gt; {
      Song.insertSong(song);
    });
  
    playlists.forEach(playlist =&gt; {
      Playlist.insertPlaylist(playlist);
    });
  };
  
  const databaseOptions = {
    path: 'playlists.realm',
    schema: [Playlist.schema, Song.schema],
  };
  let realmInstance: Realm | null;
  const getRealm = (): Realm =&gt; {
    if (realmInstance == null) {
      realmInstance = new Realm(databaseOptions);
      initData();
    }
    return realmInstance!;
  };
  
  export default getRealm;
  </code></pre>
  
  <p>I always get the error: </p>
  
  <blockquote>
    <p><code>TypeError: undefined is not an object (evaluating '_playlist.Playlist.schema')</code></p>
  </blockquote>
  
  <p>And I can't figure out why. If you need more code, just tell me.
  I am new to <code>react native</code> and <code>JavaScript</code> and <code>TypeScript</code>. I am used to developing Android apps using Java, so maybe I did some dumb mistakes, I don't know.</p>