Menu

Event Handling & Controlled Components

Event Handling & Controlled Components

A. Event handling is the process of writing functions that respond to user events such as onClick or onChange. These functions determine what happens when an action is performed.

In this project, event handlers are attached to input fields, radio buttons, and the swap button. For example, typing in an input triggers conversion instantly, and clicking the swap button changes the UI order.

B. Controlled components are form elements whose values are fully controlled by React state instead of the DOM. The input value always reflects the state.

In this project, both input fields are controlled using state variables (value1, value2). Whenever the user types, the