Redux calculator division and multiplication does not well


As a Redux noob I am experimenting with React and Redux, trying to understand the deeper part of this complicated framework in combination with state container. In the link below you will understand that the multiplication and division does not work like the addiction and subtraction button. Not sure how I should fix the multiplication and division button, so it works like a real calculator. Anyone who could help me to the right direction?

When clicking on division for example gives me the following messages: infinity and NaN. Not sure how to avoid that.

In your reducer you have:

  state.resultValue / (state.inputValue * 10 * action.number),

When I check these out, state.inputValue is 0 and action.number is NaN. That’s some funky math there.

I think you have to think about the flow here. You are trying to perform the operation before you have both of the numbers. This is not possible, unless you are building something like an RPN calculator (if you don’t know what that is, then you probably shouldn’t). So, you need to store the operation and a stack of the numbers. If they press a new operation and you have a stored operation and two numbers, then you perform the operation, show the result and clear out your stored values. Something like that.