I'm struggling to reference something on my webpage using this:
new Chessboard(document.getElementById('board3')
It is supposed to display the board, but instead I get this error:
Error: container element is null
The first answer in this link says...
This is most likely due to your script running before the page is loaded.
Why my `<div id="terminal-container">` is null?
So, how do I get around this issue where I need to create the board but I cannot do that because the id is in the return portion of the code, and so it is not yet created. I tried adding it after the return () code, but that did nothing!
Any ideas?
export const MyPiece = props => {
new Chessboard(document.getElementById('board3'), {
position:
'rn2k1r1/ppp1pp1p/3p2p1/5bn1/P7/2N2B2/1PPPPP2/2BNK1RR w Gkq - 4 11',
orientation: COLOR.black,
});
return (
<>
<DialogContent dividers>
<Typography paragraph="true">
Some text
</Typography>
<Paper id="board3"></Paper>
</DialogContent>
</>
);
};