React Event
Events is use to perform an event based on user or system action.
Events define in camel case letter e.g. onClick, onChange, etc.
- Create react project using npx create-react-app practice-app command or use the older project. practice-app is the custom project name.
2. Below is the Main component having shopMe onClick event.
3. Use below content in global index.js file to load Main component created in above steps to render above component.
4. Below is an output of above written code and it will show an alert on click of Click button.
On Change Event
Below is an example of onChange event.
Create Main.js file define an onChange event. It will print log in browser as soon as we type something inside input field box.
OUTPUT
It will print number of console logs in browser as soon as we type Test keyword in input field.
Imran Khan, Adobe Community Advisor, AEM certified developer and Java Geek, is an experienced AEM developer with over 11 years of expertise in designing and implementing robust web applications. He leverages Adobe Experience Manager, Analytics, and Target to create dynamic digital experiences. Imran possesses extensive expertise in J2EE, Sightly, Struts 2.0, Spring, Hibernate, JPA, React, HTML, jQuery, and JavaScript.