'Cannot read property 'version' of undefined Datastore Amplify React-Native

Hello is my first question on stackOverflow, Does anyone have any idea about this issue?

Im using amplify with datastore and react native

TypeError: Cannot read property 'version' of undefined at DataStore.

This error occurs when trying to use DataStore.start(), any ideas or better way to manage datastore initial sync?

Here is how i manage to do it on App.tsx:

async function startAmplifyConfig() {
  Amplify.configure(awsconfig);
  PubSub.configure(awsconfig);
  DataStore.configure();
  try {
    await DataStore.clear();
    await DataStore.start();
    await waitForDataStoreLoad();
  } catch (error) {
    console.error(error);
  }
}

const waitForDataStoreLoad = async () => {
  await new Promise<void>(resolve => {
    Hub.listen('datastore', async hubData => {
      const {event} = hubData.payload;
      if (event === 'ready') {
        resolve();
      }
    });
  });
};
startAmplifyConfig();


Sources

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

Source: Stack Overflow

Solution Source