- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2
 
CoreBlock
        Daniel Milner edited this page Sep 3, 2019 
        ·
        2 revisions
      
    The CoreBlock can be used to display any of the blocks supported by wp-block-components. When using the CoreBlock, you only need to import one component and it will take care of the rest.
import { CoreBlock } from 'wp-block-components';This component has one prop called block which accepts an object.
Example of a Heading block:
{
  __typename: '??_CoreHeadingBlock',
  attributes: {
    align: 'left',
    anchor: null,
    className: null,
    content: 'This is a heading',
    level: 2,
  },
}The ??_ in the __typename property will vary depending on your setup. As long as the __typename ends with CoreHeadingBlock, it will work.
{blocks.map((block, index) => {
  return <CoreBlock key={index} block={block} />
})}