Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

orientation with react #28

Open
bpalmer661 opened this issue Jan 7, 2023 · 0 comments
Open

orientation with react #28

bpalmer661 opened this issue Jan 7, 2023 · 0 comments

Comments

@bpalmer661
Copy link

(see code below) I am Having trouble just doing simple things with react , I have a button set orientation and it set the value to black or white though I don't see any changes on the board?

also is there any more any more examples on this being used with react, I have working website www.chessonline.app
you can just sign up with anything@mail.com (you can register using a fake email and play one game) ,

I am trying to better the user experience
at the moment if you play and move a piece to the position and then goes back to where you moved it from and then loads were you moved it too,

I would like to try and implement this board as perhaps the drag and drop is smoother?

import React, { useState, useEffect} from 'react'

import { Chessboard } from "react-chessboard";

export default function ReactChessBoard() {

const[color, setColor] = useState("black");

//eslint-disable-next-line
const setBlackOrWhite = () => {
if(color === "white"){
setColor("black")
alert("set black")

} else {
    setColor("white")
    alert("set white")
}

}

return (

<button onClick={() => {setBlackOrWhite() }}>Flip Board

<Chessboard
boardWidth="600"
id="BasicBoard"
draggable-pieces
orientation={color === "white" ? 'black' : 'white'}
>

</div>
</div>

);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant