未捕获的错误:预期onClick侦听器是一个函数,而不是类型字符串

时间:2017-06-19 17:30:56

标签: javascript reactjs listener onclicklistener event-listener

This is the button where i called the handleClick function. I think the onClick event isn't working properly (only works if i equal it to console.log('button clicked) which logs the string to the console.)

This is the handleClick() function which passes the value to the property of the component.

我不知道为什么它不起作用。以前onClick自动启动,但现在它没有问题。

P.s:我在onCLick事件中尝试了一个IIFE,它仍然将消息记录到控制台,但它似乎不适用于handleClick()

提前致谢。 :)

1 个答案:

答案 0 :(得分:1)

尝试类似:

handleClick:function(){
  return(this.props.onClick('app/src/wallpaperModule/3.jpeg'))
}