Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit b492caa

Browse files
committed
Spreading props to blocks
1 parent 42a21f1 commit b492caa

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

components/blocks/BlockSeparator/BlockSeparator.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@ import PropTypes from 'prop-types'
77
* The core Separator block from Gutenberg.
88
*
99
* @author WebDevStudios
10-
* @param props.props
11-
* @param {object} props The component attributes as props.
12-
* @param {string} props.className Optional classnames.
13-
* @param {string} props.anchor Optional anchor/id.
10+
* @param {object} props The component attributes as props.
11+
* @param {string} props.className Optional classnames.
12+
* @param {string} props.anchor Optional anchor/id.
1413
* @return {Element} The Separator component.
1514
*/
16-
export default function BlockSeparator({props}) {
17-
const {className, anchor} = props
18-
15+
export default function BlockSeparator({className, anchor}) {
1916
const isFullWidth =
2017
(className && className.includes('is-style-full-width')) > 0 ? true : false
2118

@@ -25,7 +22,6 @@ export default function BlockSeparator({props}) {
2522
}
2623

2724
BlockSeparator.propTypes = {
28-
props: PropTypes.object.isRequired,
2925
className: PropTypes.string,
3026
anchor: PropTypes.string
3127
}

components/blocks/BlockSpacer/BlockSpacer.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ import PropTypes from 'prop-types'
77
* The core Spacer block from Gutenberg.
88
*
99
* @author WebDevStudios
10-
* @param props.props
11-
* @param {object} props The component attributes as props.
12-
* @param {string} props.anchor Optional anchor/id.
13-
* @param {string} props.height The height of the spacer.
10+
* @param {object} props The component attributes as props.
11+
* @param {string} props.anchor Optional anchor/id.
12+
* @param {number} props.height The height of the spacer.
1413
* @return {Element} The Spacer component.
1514
*/
16-
export default function BlockSpacer({props}) {
17-
const {anchor, height} = props
15+
export default function BlockSpacer({anchor, height}) {
1816
return <Spacer pxHeight={height} id={anchor} />
1917
}
2018

2119
BlockSpacer.propTypes = {
22-
props: PropTypes.object.isRequired,
2320
anchor: PropTypes.string,
2421
height: PropTypes.number
2522
}
23+
BlockSpacer.defaultProps = {
24+
anchor: 50
25+
}

functions/displayBlock.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ export default function displayBlock(block, index) {
3535
case 'core/paragraph':
3636
return <Blocks.BlockParagraph props={attributes} key={index} />
3737
case 'core/separator':
38-
return <Blocks.BlockSeparator props={attributes} key={index} />
38+
return <Blocks.BlockSeparator {...attributes} key={index} />
3939
case 'core/shortcode':
4040
return <Blocks.BlockShortcode props={attributes} key={index} />
4141
case 'core/spacer':
42-
return <Blocks.BlockSpacer props={attributes} key={index} />
42+
return <Blocks.BlockSpacer {...attributes} key={index} />
4343
default:
4444
return <pre key={index}>{JSON.stringify(attributes, null, 2)}</pre>
4545
}

0 commit comments

Comments
 (0)