Skip to content

Files

Latest commit

f467e1d · Jun 18, 2024

History

History

use-block-parent-attributes

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jun 18, 2024
Jul 22, 2022

useBlockParentAttributes

The useBlockParentAttributes hook is a simple utility that makes it easy interface with the attributes of the direct parent block.

Usage

import { useBlockParentAttributes } from '@10up/block-components';

function BlockEdit(props) {
    const [parentAttributes, setParentAttributes] = useBlockParentAttributes();

    return (
        <RichText
            tagName="h2"
            value={ parentAttributes.title }
            onChange={ value => setParentAttributes({ title: value }) }
         />
    );
}