Skip to content

Instantly share code, notes, and snippets.

@jasonbahl
Created April 30, 2018 22:12
Show Gist options
  • Save jasonbahl/842a6f177a81d3f9297b06ae9ffba19f to your computer and use it in GitHub Desktop.
Save jasonbahl/842a6f177a81d3f9297b06ae9ffba19f to your computer and use it in GitHub Desktop.
Reset Gutenberg Blocks with another set of blocks
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