react/async-server-action
April 8, 2024 ยท View on GitHub
๐ Require functions with the use server directive to be async.
๐ก This rule is manually fixable by editor suggestions.
Require Server Actions (functions with the use server directive) to be async, as mandated by the use server spec.
This must be the case even if the function does not use await or return a promise.
Rule Details
Examples of incorrect code for this rule:
<form
action={() => {
'use server';
...
}}
>
...
</form>
function action() {
'use server';
...
}
Examples of correct code for this rule:
<form
action={async () => {
'use server';
...
}}
>
...
</form>
async function action() {
'use server';
...
}
When Not To Use It
If you are not using React Server Components.