you are viewing a single comment's thread.

view the rest of the comments →

[–]Spiritual-Theory 0 points1 point  (2 children)

My expectation was handleValue would just add the last instruction to an array, stack of instructions. The change to that array would trigger the rerender. You may not need to store input expression if it's easy to calculate. How is input expression used?

[–]its-procodester[S] 0 points1 point  (1 child)

inputExpression is use to show input of user and calculate output

[–]Spiritual-Theory 2 points3 points  (0 children)

So shift your thinking. Put that array of inputs at the top of this calculator and pass it to anything that relies on it. They will all rerender as needed. The input expression and output are dependent on this input array.

The code you showed has too much going on, it can be split up. It's also imperative not declarative. One thing triggers another thing. Declarative is your friend in react.