Unable to export Realm and use it an other file

I create a function, when I press it should return Item once a user is logged in. and the app compiles fine when I reload it to try and login again

  const onSaveItem = async () => {
    try {
      const realm = new Realm({
        schema: [ItemSchema],
        sync: {
          user: app.currentUser,
          partitionValue: app.currentUser.id!,
        },
      });

      const items = (await realm).objects("Item");
      return items;
    } catch (err) {
      console.log(err);
    }
  };

but when I try can create a separate file in order to import realm and use in other files for e.g redux-thunk like so:
index.ts

import Realm from "realm";
import { getRealmApp } from "../functions/realmConfig";
import { ItemSchema } from "./itemSchema";

const app = getRealmApp();

const user = app.currentUser;
const partitionValue = app.currentUser.id;

const config = {
  schema: [ItemSchema], //other schema will be added in the future
  sync: {
    user,
    partitionValue, //app.currentUser.id,
  },
};

const useRealm = new Realm(config);

export default useRealm;

and wanted to use it in my redux-thunk file
redux.ts

export const getItems = createAsyncThunk("getItems", async (user) => {
  const response = useRealm.objects("Item");
  console.log(response);
});

I get this error:

index.ts?77fd:8 Uncaught TypeError: Cannot read property 'id' of null
    at eval (index.ts?77fd:8)
    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)

I’m not even running the code but yet I’m getting an error when it compiles. I would like to know why can I not use it this way.