Chaseknis / math_magician_react

A calculator react SPA to do simple math calculations and display Math related quotes.
MIT License
1 stars 0 forks source link

Refactor with hooks #4

Open Chaseknis opened 1 year ago

Chaseknis commented 1 year ago

The function Calculator returns a JSX template and uses the useState hook to define a state object with properties total, next, and operation, and initializes them with default values 0 and null. Using the useCallback hook, The onClickHandler function takes an event and passes it to the calculate function along with the current state to update the state. The component then uses the destructuring assignment to extract the total, next, and operation properties from the state object and renders them as text. The component also defines a JSX template for a calculator UI, which includes buttons with numbers, operators, and other functions. Each button has an onClick attribute that calls the onClickHandler function.

Kamba56 commented 1 year ago

Hi @Chaseknis,

Your project is complete! There is nothing else to say other than... it's time to merge it :shipit: Congratulations! 🎉 !👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏!👏👏👏

Highlights

Optional suggestions

Every comment with the [OPTIONAL] prefix won't stop the approval of this PR. However, I strongly recommend you to take them into account as they can make your code better. Some of them were simply missed by the previous reviewer and addressing them will really improve your application.

Cheers and Happy coding!👏👏👏

Feel free to leave any questions or comments in the PR thread if something is not 100% clear. Please, remember to tag me in your question so I can receive the notification.


As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form.