Skip to content

Commit

Permalink
Set state based on previous state correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny-james committed Jun 5, 2017
1 parent 58c4735 commit 9d61284
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions blocks/library/freeform/freeform-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@ export default class FreeformBlock extends wp.element.Component {
}

setButtonActive( id, active ) {
const activeButtons = {
...this.state.activeButtons,
[ id ]: active,
};
this.setState( { activeButtons } );
this.setState( ( prevState ) => ( {
activeButtons: {
...prevState.activeButtons,
[ id ]: active,
},
} ) );
}

onSetup( editor ) {
Expand Down Expand Up @@ -217,7 +218,6 @@ export default class FreeformBlock extends wp.element.Component {

render() {
const { content, focus } = this.props;

return [
focus && (
<BlockControls
Expand Down

0 comments on commit 9d61284

Please sign in to comment.