getActionState() — astro Function Reference
Architecture documentation for the getActionState() function in actions.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 7b78e976_79b5_a302_1dfc_b121ae89b56b["getActionState()"] 06b8da53_857b_8b04_0933_f733f1198a2e["actions.ts"] 7b78e976_79b5_a302_1dfc_b121ae89b56b -->|defined in| 06b8da53_857b_8b04_0933_f733f1198a2e 2b5923e4_5066_7a86_ac92_50a2eac9cc59["withState()"] 2b5923e4_5066_7a86_ac92_50a2eac9cc59 -->|calls| 7b78e976_79b5_a302_1dfc_b121ae89b56b 50c952a5_da7b_df97_3325_ea804a54d386["isFormRequest()"] 7b78e976_79b5_a302_1dfc_b121ae89b56b -->|calls| 50c952a5_da7b_df97_3325_ea804a54d386 5efdb24b_9004_177a_063d_bd76eb5ca7c7["formData()"] 7b78e976_79b5_a302_1dfc_b121ae89b56b -->|calls| 5efdb24b_9004_177a_063d_bd76eb5ca7c7 2b5923e4_5066_7a86_ac92_50a2eac9cc59["withState()"] 7b78e976_79b5_a302_1dfc_b121ae89b56b -->|calls| 2b5923e4_5066_7a86_ac92_50a2eac9cc59 style 7b78e976_79b5_a302_1dfc_b121ae89b56b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/integrations/react/src/actions.ts lines 47–64
export async function getActionState<T>({ request }: { request: Request }): Promise<T> {
const contentType = request.headers.get('Content-Type');
if (!contentType || !isFormRequest(contentType)) {
throw new AstroError(
'`getActionState()` must be called with a form request.',
"Ensure your action uses the `accept: 'form'` option.",
);
}
const formData = await request.clone().formData();
const state = formData.get('_astroActionState')?.toString();
if (!state) {
throw new AstroError(
'`getActionState()` could not find a state object.',
'Ensure your action was passed to `useActionState()` with the `withState()` wrapper.',
);
}
return JSON.parse(state) as T;
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does getActionState() do?
getActionState() is a function in the astro codebase, defined in packages/integrations/react/src/actions.ts.
Where is getActionState() defined?
getActionState() is defined in packages/integrations/react/src/actions.ts at line 47.
What does getActionState() call?
getActionState() calls 3 function(s): formData, isFormRequest, withState.
What calls getActionState()?
getActionState() is called by 1 function(s): withState.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free