Skip to content

Commit 1e97088

Browse files
committed
Consider dispatch from useActionState and useFormState stable
1 parent b024f7e commit 1e97088

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ export default {
179179
// ^^^ true for this reference
180180
// const [state, dispatch] = useReducer() / React.useReducer()
181181
// ^^^ true for this reference
182+
// const [state, dispatch] = useActionState() / React.useActionState()
183+
// ^^^ true for this reference
184+
// const [state, dispatch] = useFormState() / ReactDOM.useFormState()
185+
// ^^^ true for this reference
182186
// const ref = useRef()
183187
// ^^^ true for this reference
184188
// const onStuff = useEffectEvent(() => {})
@@ -232,10 +236,11 @@ export default {
232236
return false;
233237
}
234238
let callee = init.callee;
235-
// Step into `= React.something` initializer.
239+
// Step into `= React(DOM).something` initializer.
236240
if (
237241
callee.type === 'MemberExpression' &&
238-
callee.object.name === 'React' &&
242+
(callee.object.name === 'React' ||
243+
callee.object.name === 'ReactDOM') &&
239244
callee.property != null &&
240245
!callee.computed
241246
) {
@@ -260,7 +265,12 @@ export default {
260265
}
261266
// useEffectEvent() return value is always unstable.
262267
return true;
263-
} else if (name === 'useState' || name === 'useReducer') {
268+
} else if (
269+
name === 'useState' ||
270+
name === 'useReducer' ||
271+
name === 'useFormState' ||
272+
name === 'useActionState'
273+
) {
264274
// Only consider second value in initializing tuple stable.
265275
if (
266276
id.type === 'ArrayPattern' &&

0 commit comments

Comments
 (0)