Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Migrated code to hooks.
Changes
useReducer
to handle complicated state without cluttering componentreducer
AppReducer.js
handleModePicker
) inuseCallback
calls to avoid re-rendering when not necessaryoperatorsByMode
, an object that matches a mode to an operator, to replace the lengthy switch statement to find out which mode belongs to which operator.eval
to evaluate the problem with the dynamic variableoperator
randomNumberGenerator(1, 9)
returns1 <= x <= 9
Notes
Changing to hooks makes React DevTools not able to see non-primitive values of hooks, to remedy this you should use an experimental version of React DevTools (it looks better too lol)
I also added a
prettier.config.js
file to make it so that when a contributor saves it doesn't reformat the entire file to their editor's style, but instead keeps it in the same style you've been writing code in (no semicolons, single quotes, tab width of 2).