Created
April 30, 2018 22:12
-
-
Save jasonbahl/842a6f177a81d3f9297b06ae9ffba19f to your computer and use it in GitHub Desktop.
Reset Gutenberg Blocks with another set of blocks
This file contains 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
class ReplaceBlocksButton extends Component { | |
render() { | |
console.log(this.props); | |
return( | |
<button onClick={this.props.clickToReset.bind(this)}>Click Me to Replace Blocks</button> | |
); | |
} | |
} | |
const WrappedReplaceBlocksButton = compose([ | |
withDispatch((dispatch) => { | |
const {resetBlocks} = dispatch('core/editor'); | |
const content = '<!-- wp:oshpd/facility-detail /-->'; | |
return { | |
clickToReset() { | |
resetBlocks( parse(content) ); | |
} | |
}; | |
}), | |
withInstanceId | |
])(ReplaceBlocksButton); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment