0

I am trying to use a react icon picker using material-ui-icon-picker

But, I get an assignment to undeclared variable showPickedIcon error

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} />
     );
},

and I can't find how to fix this.

1
  • Your variable showPickedIcon is not defined in the scope. Declare it with const, let or var and you won't have that error. Also, refrain from asking such low level questions which can be solved using a good IDE. Commented Feb 10, 2018 at 9:36

1 Answer 1

1

showPickedIcon is not declared, so give it a declaration, like this:

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} />
                );
    },
Sign up to request clarification or add additional context in comments.

1 Comment

Please make sure you point such silly mistakes in the comments rather than answering them in full.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.