oakmac / chessboardjs

JavaScript chessboard
https://chessboardjs.com
MIT License
1.98k stars 408 forks source link

Using chessboard.js with React #210

Open JonL12345 opened 3 years ago

JonL12345 commented 3 years ago

I would like to use chessboard.js with React. Has anyone here done this successfully and can point me towards some details on how to do this?

I've looked at a ton of different boards, and I see there is one for React, but it is unmaintained, so I figured it might be better to use chessboard.js for that reason. But I need to know how.

justinfagnani commented 3 years ago

I have a port of chessboard.js to web components: https://justinfagnani.github.io/chessboard-element/ and an example of using it in React here: https://stackblitz.com/edit/react-chess-board

This works because to React a web component is just another HTML element, and the internals are encapsulated in a shadow root.