willb335 / chessboardjsx

:black_square_button: Chessboard built for React
https://chessboardjsx.com
MIT License
267 stars 79 forks source link

fix(app): render consecutive updates to position from props #66

Closed hwkerr closed 3 years ago

hwkerr commented 3 years ago

Fixes issue #65 where the board would not transition from the current position to the next positionFromProps if the previousPositionFromProps and next positionFromProps represented identical board positions.

Previously, getDerivedStateFromProps in ./src/Chessboard/index.js would only update the board state if !isEqual(positionFromProps, currentPosition) && !isEqual(positionFromProps, previousPositionFromProps)

To help me better understand what was happening, I came up with these indexes to represent the different position instances used in the above conditional:

To fix the issue, I removed !isEqual(positionFromProps, previousPositionFromProps) from the conditional.

slig commented 3 years ago

Thank you very much! This fixes the issue #35 as well which was fixed using a workaround.

willb335 commented 3 years ago

@hwkerr Going to be sometime before I can publish this to npm. I lost my activation codes for npm and cannot log in and publish the package. Not sure if there is a way forward at this point. I'm in communication with GitHub at the moment to try to resolve this