React - Binary Calculator
This demo contains shows the use of nested React components to make a binary calculator.
The 3 components below are the increment button (used multiple times), the reset button and the total value.
- The IncrementButton is passed a value to display and a callback function to call when it is clicked.
- The reset button only needs a callback function to the reset logic.
- The label is passed the value of the counter state value to display.
- The increment buttons can only be clicked once each until the reset button is clicked.
- The total shows the way that an 8 bit byte can be used to represent up to 256 values (0-255).
The component should appear below, and does in development mode on the localhost but doesn't yet on the site - the next piece of the puzzle to figure out.
The code can be viewed in Plunker.
This was a first attempt at using React and contains a lot of repetition in the way that the button clicks are handled.