Site icon Hip-Hop Website Design and Development

Passing RichText attributes to perform onChange

I’ve 4 RichText parts in a customized Gutenberg block I’m growing, and they’re all very comparable aside from the "name" attribute, which is at present hard-coded. What I have to do is go within the worth of the change, and the worth of the title attribute to a perform earlier than utilizing SetAttribute. Is that this potential?

// the perform that I would like to make use of to SetAttribute after seeing the title   
const onChangeTitle = ( worth, title ) => {
    console.log(title);
};

// the RichText ingredient
<RichText
    tagName="h3"
    className="h5 text-light"
    placeholder="Link Title"
    title="linkOne"
    worth={ linkOneTitle }
    onChange={ ( worth ) => onChangeTitle( { worth, title } ) }
/>

I can submit the total code, however there are a number of completely different fields and parts that I did not need to have litter the submit. The RichText works simply fantastic and if I exploit SetAttribute within the onChangeTitle it really works with out problem to avoid wasting the title, however I have to set the title in a particular approach primarily based on the title.