Function useActorStore

  • Provides a hook for accessing the state of an actor from the actor's store. This hook is part of a set of utilities that facilitate interactions with Internet Computer (IC) canisters by abstracting the complexities associated with actor management and state retrieval.

    The useActorStore hook allows components to subscribe to and retrieve state from the actor store in a reactive way. This enables components to re-render when specific parts of the actor state change, which is managed by a selector function.

    Type Parameters

    • T

      The type of the data selected from the actor's state.

    Parameters

    Returns T

    The selected state from the actor store. The nature of the returned state depends on the selector function provided.

    Example

    // Assuming a 'LedgerActor' has been setup and used to manage the actor store
    const name = useActorStore(state => state.name);

    return <div>Canister Name: {name}</div>;

    See

    • ActorManager for more details about the architecture and management of actor stores.
    • ActorState for the structure and possible states an actor can hold.