ESLint error: ref is never reassigned, use const
With a farily simple practice app set up with TS + ESLint, there seems to be an issue when using refs in Solid. ESLint is reporting a lonely
let myForm: HTMLFormElement
as unused, despite it being passed to a ref
prop later on in the code,
The error reported by ESLint is
Is the above code following the expected patterns / best practices? The ESLint config is using Solid's plugin,
3 Replies
removing
= undefined
does the trick it seems
if it doesn't have an initial value eslint probably assumes that it will be set later
even if it isn't
so it's
or you can explicitely do ref={el => my_form = el}
Thanks, ended up going with your first suggestion,
You could also use a signal
and then use setter in the markup