Optional
deprecatedLegacyContext: anyWrap your App with AgentProvider
to provide all child components access to IC agent and authentication hooks.
<AgentProvider>
<App />
</AgentProvider>
Inside App
or any of its children, you can use the hooks provided through the context to interact with the IC,
manage authentication, and perform other agent-related tasks.
Optional
propUsed 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.
Optional
contextOptional
defaultUsed to define default values for the props accepted by the component.
type Props = { name?: string }
const MyComponent: FC<Props> = (props) => {
return <div>{props.name}</div>
}
MyComponent.defaultProps = {
name: 'John Doe'
}
Optional
displayUsed in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.
const MyComponent: FC = () => {
return <div>Hello!</div>
}
MyComponent.displayName = 'MyAwesomeComponent'
AgentProvider
is a React functional component that serves as a context provider for IC agent and authentication hooks. It enables any child components to access and use the agent and authentication functionalities seamlessly.The provider encapsulates the logic for initializing and managing an agent manager instance, which is then used to create various hooks related to agent operations and authentication processes. These hooks are made available to all child components through the context, facilitating a centralized and efficient way to interact with the Internet Computer (IC) blockchain.