Skip to content
Advertisement

How to sum, divide values of multiple inputs using onChange event | ReactJS

i try make my first App in react, everything works, but i try take amoun of bill and number of people and divide te bill for person, and add Tip. I know for somebody probably its 5 min solution but i start working with that yesterday and still can’t find solution.

I wanna take bill amount and divide by personAmount + tip if somebody choose tip. What i do wrong

JavaScript

Advertisement

Answer

Added onChange handler to the Input component and pass the different input setter functions. Then do the calculation when the tip is selected.

Try like below:

JavaScript
JavaScript
Advertisement