How to log out disabled user in react native realm app?

When I disable a user in the MongoDB realm app portal, the react native app in which they are currently logged in freezes without error. It seems to know the user ID (from what I can see from the console logs) but I’m guessing it’s something to do with their access token being revoked?

My question is: how can I automatically log out a user that has been disabled from the realm app?

At the moment, I have something like this (based on the Task tutorial):

const [user, setUser] = useState(app.currentUser);

useEffect(() => {
    if (!user) {
      console.warn('NO USER!')
      return;
    }

    try {
      getUserRealm()
    }
    catch(err) {
      console.warn('some error opening user realm', err.message);
    }

    return () => {
      if (userRealm) {
        userRealm.close();
      }
    };
  }, [user]);


async function getUserRealm() {
    
    const OpenRealmBehaviorConfiguration = {
      type: 'openImmediately',
    };
    
    const config = {
      schema: [User.schema],
      sync: {
        user: user,
        partitionValue: `user=${user.id}`,
        newRealmFileBehavior: OpenRealmBehaviorConfiguration,
        existingRealmFileBehavior: OpenRealmBehaviorConfiguration
      },
    };


    let realm = await Realm.open(config).then((userRealm) => {
 
      const users = userRealm.objects("user");
    
     // DO SOMETHING HERE WITH USERS 
     
     }).catch(error => {
      console.log(`Error opening user realm: ${error.message}`)
    });