Configuration CreateReactorParameters for the reactor, including:
withProcessEnv
(optional): Specifies whether to use process environment variables to determine if the environment is local or development. Defaults to false.withLocalEnv
(optional): Indicates if the current environment is local or development, influencing the agent and actor behavior. Useful for testing or development.port
(optional): Port number for the local or development environment.An object containing CreateReactorReturnType hooks and utilities:
import { createReactor } from "@ic-reactor/react";
import type { CreateReactorParameters } from "@ic-reactor/react/dist/types";
import { canisterId, idlFactory, yourActor } from "./declaration/yourActor"
const config: CreateReactorParameters = {
canisterId,
idlFactory,
host: "https://localhost:8000", // IC network host |
withLocalEnv: true, // Set true for local network | one of these
withProcessEnv: true, // Use process.env to determine host |
port: 8000, // Port number for local network
};
export type YourActor = typeof yourActor;
export const { useAuth, useQueryCall, useUpdateCall } = createReactor<YourActor>(config);
// Now you can use the returned hooks in your React components
Initializes and configures the reactor environment for interacting with the Internet Computer (IC) blockchain within a React application. It encapsulates the creation of actors, authentication, and agent management, offering a streamlined interface for blockchain interactions.