React onClick event on component

前端 未结 2 752
长情又很酷
长情又很酷 2020-12-13 22:59

I have a React component called that has many child s (another React component). I want to be able to decl

2条回答
  •  心在旅途
    2020-12-13 23:51

    This depends on your SensorItem component's definition. Because SensorItem isn't a native DOM element but, like you said, another React component, onClick as defined here is simply a property of that component. What you need to do is, inside of the SensorItem component pass the onClick prop to an DOM component's onClick event:

    var SensorItem = React.createClass({
      render: function() {
        return (
          
    ...
    ); } });

提交回复
热议问题