Skip to content

Commit

Permalink
fix(squares): destroy squares on unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
willb335 committed Jun 26, 2018
1 parent 09887c5 commit ac59dc0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/Chessboard/Square.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class Square extends Component {
}
}

componentWillUnmount() {
const { square } = this.props;
this[square].remove();
}

render() {
const {
connectDropTarget,
Expand Down
20 changes: 12 additions & 8 deletions src/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,25 @@ const boardStyle = {
};

class Demo extends Component {
state = { keep: true };
render() {
return (
<div style={mainContainer}>
<div style={title}>Chessboard.jsx</div>
<div style={boardsContainer}>
<div>
<div style={board}>
<Chessboard
id="standard"
calcWidth={calcWidth}
position="start"
animationOnDrop="rubberBand"
sparePieces={true}
boardStyle={boardStyle}
/>
<div onClick={() => this.setState({ keep: false })}>Hi!!!</div>
{this.state.keep && (
<Chessboard
id="standard"
calcWidth={calcWidth}
position="start"
animationOnDrop="rubberBand"
sparePieces={true}
boardStyle={boardStyle}
/>
)}
</div>
<div style={boardDescriptions}>
Standard board with spare pieces
Expand Down

0 comments on commit ac59dc0

Please sign in to comment.