Realm: user must be of type 'object', got (undefined)

Hey guys i wrote a redux-thunk function which seems to executing which which i’m not running. the code below:

export const getItems = createAsyncThunk("getItems", async (user) => {

  const response = useRealm.objects("Item").map((items) => {
    return items;
  return response;

and i wrote a realm database function which user and partitionValue are number when the app loads which shouldn’t cause a problem as there’s no function calling. code below:

export const useRealm = new Realm({
  schema: [ItemSchema],
  sync: {
    user: app?.currentUser,
    partitionValue: app?.currentUser,

But when i run the app i get this error:

index.ts?77fd:15 Uncaught Error: user must be of type 'object', got (null)
    at eval (index.ts?77fd:15)
    at Object../src/realm/index.ts (renderer.js:5394)
    at __webpack_require__ (renderer.js:791)
    at fn (renderer.js:102)
    at eval (index.ts?788b:2)
    at Object../src/redux/testReducer/index.ts (renderer.js:5427)
    at __webpack_require__ (renderer.js:791)
    at fn (renderer.js:102)
    at eval (index.ts?76a6:9)
    at Object../src/redux/index.ts (renderer.js:5416)

is there another way to bypass it?

1 Like

Having the same issue in react native

<UserProvider fallback={LogIn}>
          user: app.currentUser,
          flexible: true,
          onError: (_, error) => {

ERROR [Error: Exception in HostFunction: user must be of type 'object', got (null)]

The problem for me was that the UserProvider already took care of supplying the user to realm, so i had to remove the user altogether from the sync objet. For [Tony_Ngomana] I know this is an old issue but if you didn’t manage to solve you problem, have you tried user: app.allUsers[0] since the type of app?.currentUser isn’t compatible with the user’s attribute type.