1

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 e.g. 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.

coreyl
  • 67
  • 1
  • 10
  • Have you tried like this inside a block. it should work `onClick={() => {changeLanguage('zh'); this.props.lang_zh;}}` – abdul Mar 12 '18 at 07:24
  • Were you able to find a solution to this? The answers I've seen are causing an error "Expected an assignment or function call but instead saw an expression." – Christine Feb 09 '19 at 21:36

1 Answers1

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

How about this?

Neeraj
  • 483
  • 9
  • 17