r/reactjs • • Jun 03 '18

Beginner's Thread / Easy Question (June 2018)

Hello! just helping out /u/acemarke to post a beginner's thread for June! we had over 270 comments in last month's thread! If you didn't get a response there, please ask again here! You are guaranteed a response here!

Soo... Got questions about React or anything else in its ecosystem? Stuck making progress on your app? Ask away! We’re a friendly bunch. No question is too simple.

The Reactiflux chat channels on Discord are another great place to ask for help as well.

Pre-empting the most common question: how to get started learning react?

You might want to look through /u/acemarke's suggested resources for learning React and his React/Redux links list. Also check out http://kcd.im/beginner-react.

32 Upvotes

537 comments sorted by

View all comments

Show parent comment

2

u/m_plis Jun 29 '18

Custom components (e.g. <Hello />) don't work the same as native DOM elements (e.g. <div />). That's why <div onClick={this.handleClick} is not going to do the same thing as <Hello onClick={this.handleClick} />.

The former will actually bind the event handler to that DOM element so the browser can trigger it at the appropriate time. The latter simply passes the function as a prop to your custom component. Just like with any other prop, nothing happens with them unless the component makes use of them.