Function ActorManagerProvider

  • ActorManagerProvider is a React functional component that serves as a context provider for IC actor managers within a React application. It wraps child components, providing them access to actor-specific manager functionalities based on the provided actor manager and configuration.

    Props:

    • actorManager: ActorManager - The actor manager object containing the actor manager functionalities.
    • children: React Node - The child components that will have access to the actor manager context.

    Behavior:

    • Validates the presence of the actorManager. Throws an error if it is missing, ensuring that the actor manager is always available for actor operations.
    • Utilizes useMemo to memoize the actorManager, optimizing for performance by avoiding unnecessary recalculations.
    • Renders the child components once the actorManager is available, effectively providing them access to the actor manager context.

    Parameters

    Returns ReactNode

    Example

    <ActorManagerProvider actorManager={yourActorManager}>
    <YourComponent />
    </ActorManagerProvider>

    This setup ensures that YourComponent and any of its children can interact with the specified IC actor manager through the context provided by ActorManagerProvider.

Properties

propTypes?: WeakValidationMap<ActorManagerProviderProps<types.BaseActor>>

Used to declare the types of the props accepted by the component. These types will be checked during rendering and in development only.

We recommend using TypeScript instead of checking prop types at runtime.

contextTypes?: ValidationMap<any>

Deprecated

Lets you specify which legacy context is consumed by this component.

See

Legacy React Docs

Used to define default values for the props accepted by the component.

See

React Docs

Example

type Props = { name?: string }

const MyComponent: FC<Props> = (props) => {
return <div>{props.name}</div>
}

MyComponent.defaultProps = {
name: 'John Doe'
}

Deprecated

Use values for destructuring assignments instead.

displayName?: string

Used in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.

See

Legacy React Docs

Example


const MyComponent: FC = () => {
return <div>Hello!</div>
}

MyComponent.displayName = 'MyAwesomeComponent'