Actions
Actions enable you to make changes to the internal AppState via the dispatcher.
This is a partial reference of the most useful actions. A full reference is available in the codebase (opens in a new tab).
Types
setData
Modify the data payload currently managed by Puck.
Param | Example | Type | Status |
---|---|---|---|
type | type: "setData" | "setData" | Required |
data | data: {} | Data | Required |
Example
dispatch({
type: "setData",
data: {},
});
setUi
Change a value on Puck's UI state.
Param | Example | Type | Status |
---|---|---|---|
type | type: "setData" | "setData" | Required |
ui | ui: { leftSideBarVisible: false } | UiState | Required |
Example
dispatch({
type: "setUi",
ui: {
leftSideBarVisible: false,
},
});
set
Change the entire AppState in a single action.
Param | Example | Type | Status |
---|---|---|---|
type | type: "setData" | "setData" | Required |
state | state: { data: {}, ui: {} } | AppState | Required |
Example
dispatch({
type: "set",
state: { data: {}, ui: {} },
});