简体   繁体   中英

react passing multiple functions to components and invoking onClick

I'm passing a function to a component (which works btw, loads language translated product list as json) :

<a onClick={this.props.lang_zh} href="#">ZH</a></li>

I also have a translation function (which works, translates all other content eg UI, text elements). This is a child component btw, i18n-react:

<a onClick={() => changeLanguage('zh')} href="#">ZH</a>

I need them both to load, but when I combine them onClick the passed props are not being received.

this answer addresses multiple functions but neither separate method, inline arrow functions are working with combination of function and props (which type is function btw not string). Any info/feeback appreciated.

onclick={()=>{ this.props.lang_zh(); changeLanguage('zh'); }}

这个怎么样?

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