最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

block editor - Import setAttributes() method in a separated module

programmeradmin0浏览0评论

Is there a possibility to import the setAttributes() method in a separated module, I mean in what package we can find that method outside the props of edit and save functions

Example: This is a separated component that is gonna be used in the inspector of a specific block:

export default class Color extends Component {
    constructor(props) {
        super(...arguments);
    }

    render() {
      <div>
        <RangeControl
                help="Color"
                value={color}
                onChange={value => setAttributes({color: value})}
                min={0}
                        max={20}
        />
     </div>
    }

There is a possibility to pass the setAttributes method using the spread opera tor on the component

<Color {...this.props.setAttributes} />

but I want something like:

const { setAttributes } = wp.packageName; 

Thanks!

发布评论

评论列表(0)

  1. 暂无评论