Skip to content

Latest commit

 

History

History
33 lines (19 loc) · 2.32 KB

File metadata and controls

33 lines (19 loc) · 2.32 KB

Action

An action in your created component is an async callback function that allows you to read contextual information about the action being dispatched, along with information about the component that is initiating the call.

It can be defined in an async function inside the createComponent call, and includes 3 arguments:

action: async (element, action, context) => {
    return {}
},

element

The element calling the action. This object contains the following keys:

NameDescription
propsProps attached to the current instance of the component
stateThe local state of the component
contextInformation about the context of the component. Includes it's type, editable status, and the current theme.
setCacheSet the cache max-age for the output of this component.
dynamicStateReturn an identifier for a dynamic state binding.

action

The main action object being sent. See the Actions reference to learn more about the GitBook specific actions your components can read, or how to create your own custom actions for your integrations.

This object contains the following key:

NameDescription
actionThe name of the action being dispatched. It can be either a default GitBook action, or a custom defined action. See the Actions reference to learn more.

context

Context about your integration, including the environment and installation details the integration is running in.

This object contains the following keys:

NameDescription
environmentEnvironment of the integration. See the Environment section to learn more.
apiAuthenticated client to the GitBook API. See the API docs to learn more.