Skip to content Skip to sidebar Skip to footer

OnClick="" Don't Appear At The Actual Element Made With React.

I'm making some elements with react like this: var AddNewTask = React.createClass({ handleClick: function() { console.log('pressed!'); }, render: function() { return (

Solution 1:

It won't appear in the rendered HTML, as the handler is attached to the DOM element itself. React also normalizes the event system across browsers so that it behaves consistently. I would suggest reading up on how it works at the official docs: https://facebook.github.io/react/docs/events.html


Solution 2:

Simply put:

  1. onClick on jsx is not DOM-onClick-event but React-onClick-event.
  2. React-onClick-event is belong to React, so it's not displayed on DOM.
  3. React.js automatically convert React-onClick-event into DOM-onClick-event behind the scene.

Post a Comment for "OnClick="" Don't Appear At The Actual Element Made With React."