-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Charles Lee Zhao Yi - Guess The Word #56
base: main
Are you sure you want to change the base?
Conversation
…ith alerts and appropriate resets
…ensure uppercase letters are checked properly
this.state.guessedLetters.pop | ||
), | ||
}); | ||
alert("Please enter only one letter at a time."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to avoid alerts. Alerts block the user from interacting from your website, thus it is an anti-pattern to what React is trying to achieve. I suggest rather some red text that shows this validation warning or something along these lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great point. I'll look into inline error messaging in future implementations. Thanks Rob!
type="text" | ||
value={this.state.formInput} | ||
onChange={this.handleChange} | ||
></input> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
></input> | |
/> |
@@ -43,8 +91,21 @@ class App extends React.Component { | |||
? this.state.guessedLetters.toString() | |||
: "-"} | |||
<h3>Input</h3> | |||
{/* Insert form element here */} | |||
Todo: Insert form element here | |||
<form onSubmit={this.handleSubmit}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are using buttons below for submission, the <form>
tag is redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback Rob - will keep in mind for future implementations!
{this.state.numGuessesLeft > 1 ? ( | ||
<button onClick={this.handleSubmit}>Submit</button> | ||
) : ( | ||
<button onClick={this.handleSubmit} disabled> | ||
Submit | ||
</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{this.state.numGuessesLeft > 1 ? ( | |
<button onClick={this.handleSubmit}>Submit</button> | |
) : ( | |
<button onClick={this.handleSubmit} disabled> | |
Submit | |
</button> | |
<button onClick={this.handleSubmit} disabled={!this.state.numGuessesLeft}>Submit</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, should the > 1 not be >= 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch - I should have caught this in my implementation. Will improve in logic in future. Thanks Rob!
PR for Guess The Word Assignment. Added exception handling and alerts.