简体   繁体   中英

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 onClick event:

  deleteTag = (event) => {

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

  }

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

Thanks in advance!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM