Nkaleth / Math-magicians

"Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: make simple calculations, read a random math-related quote. By building this application,I will learn how to use React.
https://reactproject-math-magicians.onrender.com/
1 stars 0 forks source link

Use React hooks. #4

Open Nkaleth opened 1 year ago

Nkaleth commented 1 year ago

I used the useStatehook in this line to add a state variable to Calculator component, the initial state is {} :

https://github.com/Nkaleth/Math-magicians/blob/095dbaaae5b53d974180a0a0efda88fa5fe57d1b/src/components/Calculator.js#L7

Then I update the state in this line with the calculate function with the current state and the string of the clicked button:

https://github.com/Nkaleth/Math-magicians/blob/095dbaaae5b53d974180a0a0efda88fa5fe57d1b/src/components/Calculator.js#L10

Finally, when the state has been changed, react detecs it and start a re-render of the calculator component, specifically this <p></p tag which its inner text depends on the new state.

https://github.com/Nkaleth/Math-magicians/blob/095dbaaae5b53d974180a0a0efda88fa5fe57d1b/src/components/Calculator.js#L15

CollinsTatang commented 1 year ago

Approved 👏

Highlights 🚀 :heavy_check_mark: :heavy_check_mark:

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

Congratulations! 🎉

image

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 @CollinsTatang 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.