D
D
Dmitry Avilov2020-08-03 17:14:06
React
Dmitry Avilov, 2020-08-03 17:14:06

How to implement calculations in state having values ​​of other components?

Hello.
I'm learning react + redax and writing my application for calculating a cash contribution.
State:
5f281a4ecba9f633573298.png

First page interface:
5f2819b6a0742218758298.png

When data is filled in textField's, the state is updated via flux dispatches (via onChange)

and by clicking on the "CALCULATE" button, the "totalAmount" is calculated and the value in the state is set.

How can I implement the calculation of the "percentageValue" parameter by: (totalAmount - deposite) from state?
I need this value to display the amount of accrued interest on the deposit in the sledge.

If the solution is elementary, then please do not swear, I'm learning)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
t800zippygod, 2020-08-03
@t800zippygod

I don’t remember exactly the implementation of pure Flux, I’ll tell you on the example of Redux, based on the Flux concept. When a specific event fires, an action is created, it contains data for changing the state (if required) and the name of the action. Then this action is thrown into the reducer, which, depending on the name of the action, creates a new changed state and returns it.
The only thing is that in flux instead of a reducer, dispatchers are used

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question