S
SolidJS16mo ago
stiba

solid-js reactivity eslint with functions

I'm getting the following warning: This function should be passed to a tracked scope (like createEffect) or an event handler because it contains reactivity.eslintsolid/reactivity
<MyComponent
onPriorityChanged={(priority) =>
props.onTaskPriorityChanged(task.id, priority)
}
onStatusChanged={(status) =>
props.onTaskStatusChanged(task.id, status)
}
onAssigned={(assigneeId) =>
props.onTaskAssigned(task.id, assigneeId)
}
/>
<MyComponent
onPriorityChanged={(priority) =>
props.onTaskPriorityChanged(task.id, priority)
}
onStatusChanged={(status) =>
props.onTaskStatusChanged(task.id, status)
}
onAssigned={(assigneeId) =>
props.onTaskAssigned(task.id, assigneeId)
}
/>
What am I doing wrong here? I tried looking at the eslint-plugin docs but I'm not getting any wiser
4 Replies
stiba
stiba16mo ago
Okay so I see that you're supposed to do something along these lines
<MyComponent
onStatusChanged={[props.onTaskStatusChanged, status]}
/>
<MyComponent
onStatusChanged={[props.onTaskStatusChanged, status]}
/>
This still doesn't solve my problem though when I have a function that I'm passing down the tree. It takes 2 arguments, and in one of the children I create a new function that passes the first argument, and then the child only needs to supply one argument
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
stiba
stiba16mo ago
Are there any codesandbox templates or similar with the plugin configured?
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View