Closed Dima-369 closed 6 months ago
This code does not trigger the warning. Is this the preferred way of doing this? I am asking since it doesn't use createRoot()
which the tutorial sometimes uses.
export const [setTest, getTest] = createSignal('');
For proper analysis, array destructuring should be used to capture the first result of this function call.(solid/reactivity)
This is just letting you know that the reactivity
rule can't analyze how the signal returned from createSignal
is used. Currently, the rule's analysis relies on variables, so returning directly prevents it from working.
This doesn't mean there's anything wrong with your codeβit's just trying to help you make the most out of using the reactivity
rule. By pushing you to write code like
function create() {
const [signal, setSignal] = createSignal(0);
return [signal, setSignal];
}
you're getting better static analysis in exchange for a little bit more verbosity. In the future, I'm hoping to remove this restriction and handle returning reactive expressions directly.
you're getting better static analysis in exchange for a little bit more verbosity.
Thanks for your answer, then the verbosity is surely worth it!
I used the code in this tutorial: https://www.solidjs.com/tutorial/stores_nocontext?solved
It shows this warning: ESLint: For proper analysis, array destructuring should be used to capture the first result of this function call.(solid/reactivity)
I wondered if the warning is correct.
Here is another case where the warning is shown:
And it goes away like this:(bad code, those aren't the same)Sorry, if this has been asked before, there is a lot of info on the reactivity warning π