react - react events - ReactJS Events - react js - reactjs
What is Events in ReactJS?
- Handling events with React elements is very similar to handling events on DOM elements. There are some syntactic differences:
- React events are named using camelCase, rather than lowercase.
- With JSX you pass a function as the event handler, rather than a string.
learn reactjs tutorial -
reactjs events
- reactjs example - react tutorial - reactjs - react
Example
- This is simple example where we only use one component.
- We are just adding onClick event that will trigger updateState function once the button is clicked.
App.jsx
Article tag : react , react native , react js tutorial , create react app , react tutorial , learn react
main.js
Output
learn reactjs tutorial -
reactjs events
- reactjs example - react tutorial - reactjs - react
Child Events
- When you need to update state of the parent component from its child
- you can create event handler (updateState) in the parent component and pass it as a prop (updateStateProp) to your child component where you can just call it.