user1547174 user1547174 - 1 year ago 64
Javascript Question

Return value prop of component in reactjs

Right now I have a component:

<Icon name='close' value={ tag } onClick={ this.deleteTag.bind(this) } />

And an

deleteTag = (event) => {

const tag = event.currentTarget.value; //returns undefined


Is there a way I can return the
prop of my
component? My attempt as shown above would not work...

Thanks in advance!

Answer Source

The Icon itself, does not have a value.. It's not an input

What you could do, is the following:

<Icon name='close' value={ tag } onClick={ () => this.deleteTag(tag) } />

Now the tag should be available in your deleteTag method.