diff --git a/docs/reactivity.md b/docs/reactivity.md
index 81be87c..cd50ae7 100644
--- a/docs/reactivity.md
+++ b/docs/reactivity.md
@@ -816,6 +816,12 @@ function Component(props) {
return
props.count} />;
}
+function formObjectDispatch(formObject, action) {
+ const { field } = action.payload;
+ formObject.findIndex((props) => props.field === field);
+ formObject.findIndex((props) => props.field === field);
+}
+
```
diff --git a/src/rules/reactivity.ts b/src/rules/reactivity.ts
index 2d1b507..0226fe7 100644
--- a/src/rules/reactivity.ts
+++ b/src/rules/reactivity.ts
@@ -315,11 +315,11 @@ export default createRule
({
/** Populates the function stack. */
const onFunctionEnter = (node: ProgramOrFunctionNode) => {
if (isFunctionNode(node)) {
- markPropsOnCondition(node, (props) => isPropsByName(props.name));
if (scopeStack.syncCallbacks.has(node)) {
// Ignore sync callbacks like Array#forEach and certain Solid primitives
return;
}
+ markPropsOnCondition(node, (props) => isPropsByName(props.name));
}
scopeStack.push(new ScopeStackItem(node));
};
diff --git a/test/rules/reactivity.test.ts b/test/rules/reactivity.test.ts
index b9c74d9..ae90419 100644
--- a/test/rules/reactivity.test.ts
+++ b/test/rules/reactivity.test.ts
@@ -328,6 +328,12 @@ export const cases = run("reactivity", rule, {
function Component(props) {
return props.count} />;
}`,
+ // f*cking insane edge case with multiple functions taking props as sync callbacks (#110)
+ `function formObjectDispatch(formObject, action) {
+ const { field } = action.payload;
+ formObject.findIndex((props) => props.field === field);
+ formObject.findIndex((props) => props.field === field);
+ }`,
],
invalid: [
// Untracked signals