Open
Conversation
kaytijackson97
left a comment
There was a problem hiding this comment.
Looking really nice! Well done converting those components into functional components! Remember that you can import useState and other hooks from react to clean up your code and to keep good indentation
| import React from "react"; | ||
| import Button from "./Button"; | ||
| function GuessControl({ onGuess }) { | ||
| const [currentGuess, setCurrentGuess] = React.useState(''); |
There was a problem hiding this comment.
you can import useState from react to prevent from re-writing React
| const[numberToGuess, setNumberToGuess]= React.useState(getRandomNumber()); | ||
| const[numberOfGuesses, setNumberOfGuesses]= React.useState(0); | ||
| const[latestGuess, setLatestGuess]= React.useState(null); | ||
| function handleGuess(guess) { |
There was a problem hiding this comment.
fix indentation to match state variable indentation
| const isCorrectGuess = this.state.latestGuess === this.state.numberToGuess; | ||
|
|
||
| function NumberGuessingGame() { | ||
| const[numberToGuess, setNumberToGuess]= React.useState(getRandomNumber()); |
There was a problem hiding this comment.
can import useState like mentioned above
Owner
Author
|
Yes I remember your comments but the problem is you send me the feedback after I submitted this assignment that is you it happened again this thing. 🙏
…Sent from my iPhone
On Nov 10, 2021, at 10:13 PM, kaytiwiita ***@***.***> wrote:
@kaytiwiita commented on this pull request.
Looking really nice! Well done converting those components into functional components! Remember that you can import useState and other hooks from react to clean up your code and to keep good indentation
In src/GuessControl.js:
> import Button from "./Button";
+function GuessControl({ onGuess }) {
+ const [currentGuess, setCurrentGuess] = React.useState('');
you can import useState from react to prevent from re-writing React
In src/NumberGuessingGame.js:
> - handleReset() {
- this.setState({
- numberToGuess: getRandomNumber(),
- numberOfGuesses: 0,
- latestGuess: null,
- });
- }
-
- render() {
- const isCorrectGuess = this.state.latestGuess === this.state.numberToGuess;
-
+function NumberGuessingGame() {
+ const[numberToGuess, setNumberToGuess]= React.useState(getRandomNumber());
+ const[numberOfGuesses, setNumberOfGuesses]= React.useState(0);
+ const[latestGuess, setLatestGuess]= React.useState(null);
+function handleGuess(guess) {
fix indentation to match state variable indentation
In src/NumberGuessingGame.js:
> - });
- }
-
- handleReset() {
- this.setState({
- numberToGuess: getRandomNumber(),
- numberOfGuesses: 0,
- latestGuess: null,
- });
- }
-
- render() {
- const isCorrectGuess = this.state.latestGuess === this.state.numberToGuess;
-
+function NumberGuessingGame() {
+ const[numberToGuess, setNumberToGuess]= React.useState(getRandomNumber());
can import useState like mentioned above
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.