When I try to use Svelte's bind:this
attribute, I get this shown in vscode:
'cardGroup' is possibly 'undefined'.js(18048)
And when run, I get this error:
TypeError: Cannot read properties of undefined (reading 'childNodes')
I was originally working in Typescript where I got the error that the bound variable was not declared before usage.
Script:
let cardGroup; let cardContainers = cardGroup.childNodes; console.log(cardContainers.length);
HTML:
<div class="cardGroup" bind:this={cardGroup}> [content]</div>
It is entirely possible that I'm missing something but I haven't found anything using this binding that isnt doing exactly what I am, from what I can tell.