Closed
Conversation
…is allows parent components to interact with the Chessground API, e.g. make moves on the board, reset the board. Add arrows.
Contributor
|
Hey, thanks so much for opening this PR :) This is quite a nice approach, but I'm wondering if it's cleaner to expose the api through that way we can more easily expose other control methods to the parent, maybe we can even build a few helpers on top of the exposed api to make controlling the chess board easier |
Author
|
Closing in preference for #16 which uses forwardRef and useImperativeHandler. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current React component doesn't expose the Chessground API in it's interface, which makes it difficult to interact directly with the board from other components.
I've surfaced the API in a callback props called
onApiReady. This makes the Chessground API available to calling code, and allows interactions like making a move on the board, resetting the board to a new position, and adding arrows. API interface documentation here: https://github.com/lichess-org/chessground/blob/master/src/api.tsSample code demonstrating its use: