Function useObject

  • Returns a Realm.Object from a given type and value of primary key. The hook will update on any changes to the properties on the returned object and return null if it either doesn't exists or has been deleted.

    Type Parameters

    • T

    Parameters

    • options: ObjectHookOptions<T>

    Returns null | T & Object<T, never>

    either the desired Realm.Object or null in the case of it being deleted or not existing.

    Example

    const object = useObject(ObjectClass, objectId);
    
  • Returns a Realm.Object from a given type and value of primary key. The hook will update on any changes to the properties on the returned object and return null if it either doesn't exists or has been deleted.

    Type Parameters

    Parameters

    • options: ObjectHookClassBasedOptions<T>

    Returns null | T

    either the desired Realm.Object or null in the case of it being deleted or not existing.

    Example

    const object = useObject(ObjectClass, objectId);
    
  • Returns a Realm.Object from a given type and value of primary key. The hook will update on any changes to the properties on the returned object and return null if it either doesn't exists or has been deleted.

    Type Parameters

    • T

    Parameters

    • type: string

      The object type, depicted by a string or a class extending Realm.Object

    • primaryKey: T[keyof T]

      The primary key of the desired object which will be retrieved using Realm.objectForPrimaryKey

    • Optional keyPaths: string | string[]

      Indicates a lower bound on the changes relevant for the hook. This is a lower bound, since if multiple hooks add listeners (each with their own keyPaths) the union of these key-paths will determine the changes that are considered relevant for all listeners registered on the object. In other words: A listener might fire and cause a re-render more than the key-paths specify, if other listeners with different key-paths are present.

    Returns null | T & Object<T, never>

    either the desired Realm.Object or null in the case of it being deleted or not existing.

    Example

    const object = useObject(ObjectClass, objectId);
    
  • Returns a Realm.Object from a given type and value of primary key. The hook will update on any changes to the properties on the returned object and return null if it either doesn't exists or has been deleted.

    Type Parameters

    Parameters

    • type: RealmClassType<T>

      The object type, depicted by a string or a class extending Realm.Object

    • primaryKey: T[keyof T]

      The primary key of the desired object which will be retrieved using Realm.objectForPrimaryKey

    • Optional keyPaths: string | string[]

      Indicates a lower bound on the changes relevant for the hook. This is a lower bound, since if multiple hooks add listeners (each with their own keyPaths) the union of these key-paths will determine the changes that are considered relevant for all listeners registered on the object. In other words: A listener might fire and cause a re-render more than the key-paths specify, if other listeners with different key-paths are present.

    Returns null | T

    either the desired Realm.Object or null in the case of it being deleted or not existing.

    Example

    const object = useObject(ObjectClass, objectId);
    

Generated using TypeDoc