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

Usage with react #20

Closed
m-misha93 opened this issue Jul 26, 2020 · 7 comments
Closed

Usage with react #20

m-misha93 opened this issue Jul 26, 2020 · 7 comments
Labels

Comments

@m-misha93
Copy link

What about React. Can i use it?

@shaack
Copy link
Owner

shaack commented Jul 27, 2020

Have not tried it, if you do, please report if it works. I think it should.... why not?

@m-misha93
Copy link
Author

it render board, but move, animation not work

@shaack
Copy link
Owner

shaack commented Jul 31, 2020

Can you provide a link to a testpage?

@m-misha93
Copy link
Author

@m-misha93
Copy link
Author

change inputHandler. it work

@shaack
Copy link
Owner

shaack commented Aug 5, 2020

Okay,... nice... can you give more details? Thanks.

@shaack shaack closed this as completed Aug 8, 2020
@m-misha93
Copy link
Author

m-misha93 commented Aug 10, 2020

use inputHandler like in example

inputHandler = (event) => {
    if (event.type === INPUT_EVENT_TYPE.moveDone) {
        const move = {from: event.squareFrom, to: event.squareTo}
        const result = this.game.move(move)
        if (result) {
            this.setState(() => ({
                fen: this.game.fen(),
                history: this.game.history({verbose: true}),
                squareStyles: squareStyling({toSquare: event.squareTo, history: this.game.history({verbose: true})}),
            }))

        } else {
            console.warn("invalid move", move)
        }
        return result
    } else {
        return true
    }
}

@shaack shaack changed the title Can i use it with react? Usage with react Aug 18, 2020
@shaack shaack added the howto label May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants