获取“分配给未声明的变量”错误

时间:2018-02-10 09:14:47

标签: javascript reactjs

我正在尝试使用material-ui-icon-picker

的反应图标选择器

但是,我得到赋予未声明的变量showPickedIcon 错误

edit( { attributes, className, focus, setAttributes, setFocus, setState  } ) {
     const { content, alignment ,applyStyles,icon} = attributes;
     showPickedIcon = (icon) => {
         console.info(icon) // prints {name: "access_alarm", code: "e190"}
     }

     return (
         <MaterialUiIconPicker onPick={this.showPickedIcon} />
     );
},

我找不到如何解决这个问题。

1 个答案:

答案 0 :(得分:0)

未声明showPickedIcon,因此请给它一个声明,如下所示:

edit( { attributes, className, focus, setAttributes, setFocus, setState  } ) {
        const { content, alignment ,applyStyles,icon} = attributes;
        const showPickedIcon = (icon) => {
        console.info(icon) // prints {name: "access_alarm", code: "e190"}
    }


        return (
                <MaterialUiIconPicker onPick={this.showPickedIcon} />
                );
    },