Home / Function/ injectStateIntoFormActionData() — astro Function Reference

injectStateIntoFormActionData() — astro Function Reference

Architecture documentation for the injectStateIntoFormActionData() function in actions.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  3a333565_63d0_d54e_2988_717e0999827f["injectStateIntoFormActionData()"]
  06b8da53_857b_8b04_0933_f733f1198a2e["actions.ts"]
  3a333565_63d0_d54e_2988_717e0999827f -->|defined in| 06b8da53_857b_8b04_0933_f733f1198a2e
  2b5923e4_5066_7a86_ac92_50a2eac9cc59["withState()"]
  2b5923e4_5066_7a86_ac92_50a2eac9cc59 -->|calls| 3a333565_63d0_d54e_2988_717e0999827f
  style 3a333565_63d0_d54e_2988_717e0999827f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/react/src/actions.ts lines 81–100

function injectStateIntoFormActionData<R extends [this: unknown, state: unknown, ...unknown[]]>(
	fn: (...args: R) => unknown,
	...args: R
) {
	const boundFn = Function.prototype.bind.call(fn, ...args);
	Object.assign(boundFn, fn);
	const [, state] = args;

	if ('$$FORM_ACTION' in fn && typeof fn.$$FORM_ACTION === 'function') {
		const metadata = fn.$$FORM_ACTION();
		boundFn.$$FORM_ACTION = () => {
			const data = (metadata.data as FormData) ?? new FormData();
			data.set('_astroActionState', JSON.stringify(state));
			metadata.data = data;

			return metadata;
		};
	}
	return boundFn;
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does injectStateIntoFormActionData() do?
injectStateIntoFormActionData() is a function in the astro codebase, defined in packages/integrations/react/src/actions.ts.
Where is injectStateIntoFormActionData() defined?
injectStateIntoFormActionData() is defined in packages/integrations/react/src/actions.ts at line 81.
What calls injectStateIntoFormActionData()?
injectStateIntoFormActionData() 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