Skip to content

Commit

Permalink
Refactor actor and agent context setup
Browse files Browse the repository at this point in the history
  • Loading branch information
b3hr4d committed Apr 4, 2024
1 parent 89bab92 commit 495e041
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
5 changes: 2 additions & 3 deletions packages/react/src/context/actor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ import { extractActorContext } from "../helpers/extractActorContext"
* };
* ```
*
* This function streamlines the process of setting up a context for IC actor interactions within a React app, making it easier
* to manage actor state and perform actions such as queries or updates. It abstracts away the complexities involved in directly
* managing IC agents and actors, providing a simple, declarative API for developers.
* This function streamlines the process of setting up a context for IC actor interactions within a React app,
* it provides a type-safe and efficient way to manage actor state and interactions.
*/
export function createActorContext<A = BaseActor>(
contextConfig: CreateActorContextParameters = {}
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/context/agent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import { isInLocalOrDevelopment } from "../utils"
* Hooks extracted from the created context for managing agent and authentication state within components.
*
* @example
* agent.ts
* ```tsx
* // agent.ts
* import { createAgentContext } from "@ic-reactor/react";
* import { CreateAgentCotextParameters } from "@ic-reactor/react/dist/types";
*
Expand All @@ -50,11 +50,11 @@ import { isInLocalOrDevelopment } from "../utils"
* useAgentManager,
* useUserPrincipal,
* } = createAgentContext(agentConfig);
*
* // Now you can use the returned hooks in your React components
*```
* App.tsx
* Now you can use the returned hooks in your React components
*
* ```tsx
* // App.tsx
* import React from 'react';
* import { AgentProvider } from './agent';
*
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/context/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ export interface CreateActorContextParameters
didjsId?: string
canisterId?: string
idlFactory?: IDL.InterfaceFactory
loadingComponent?: React.ReactNode
}
6 changes: 4 additions & 2 deletions packages/react/src/provider/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { ActorHooks } from "../hooks/actor/hooks"
* It wraps child components, providing them access to actor-specific hooks and functionalities based on the provided canister ID and configuration.
*
* Props:
* - `children`: React Node - The child components that will have access to the actor context.
* - `canisterId` (optional): string - The Canister ID for actor interactions. If not provided, the default from `createActorContext` is used.
* - `idlFactory` (optional): IDL.InterfaceFactory - The IDL factory for the actor interface. If not provided, the default from `createActorContext` is used.
* - `didjsId` (optional): string - The DID.js ID for authentication. If not provided, the default from `createActorContext` is used.
* - `loadingComponent` (optional): React Node - A component displayed during the loading/fetching state. Defaults to a simple message.
* - `...restConfig`: Additional configuration options that will be merged with the default configuration provided during context creation.
* - `authenticatingComponent` (optional): React Node - A component displayed during the authentication state. Defaults to a simple message.
* - `children`: React Node - The child components that will have access to the actor context.
*
* Behavior:
* - Validates the presence of a `canisterId`. Throws an error if it is missing, ensuring that a valid canister ID is always used for actor operations.
Expand Down
2 changes: 1 addition & 1 deletion typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "ic-reactor",
"customTitle": "ic-reactor",
"navigationLinks": {
"Examples": "https://github.com/B3Pay/ic-reactor/tree/main/examples",
"Example": "https://github.com/B3Pay/ic-reactor/tree/main/examples",
"GitHub": "https://github.com/B3Pay/ic-reactor"
},
"cleanOutputDir": true,
Expand Down

0 comments on commit 495e041

Please sign in to comment.