converted CreateUserForm.js to functional components#738
Open
huangdarren1106 wants to merge 1 commit intouclaacm:masterfrom
Open
converted CreateUserForm.js to functional components#738huangdarren1106 wants to merge 1 commit intouclaacm:masterfrom
huangdarren1106 wants to merge 1 commit intouclaacm:masterfrom
Conversation
af07613 to
68e1297
Compare
Contributor
|
@huangdarren1106 can you make a comment when you are ready for review? thanks!! |
timothycpoon
suggested changes
Nov 17, 2021
| const { username, password, confirmPassword } = this.state; | ||
| const validateInputs = () => { | ||
| // const { username, password, confirmPassword } = state; | ||
| const username1 = username; |
Contributor
There was a problem hiding this comment.
What is the purpose of these 3 vars? I think you can just use username, etc
| }; | ||
|
|
||
| updateUsername = (username) => this.setState({ username }); | ||
| const updateUsername = (newusername) => setusername(newusername); |
Contributor
There was a problem hiding this comment.
these 3 functions can be removed and replaced with the set functions
| export default function CreateUserForm(props) { | ||
| // const init = props.initialState; | ||
| const { initialState } = props; | ||
| const [username, setusername] = useState(initialState ? initialState.username : ''); |
Contributor
There was a problem hiding this comment.
For consistency's sake, let's name these in camelCase, e.g. setUsername
| color: textColor, | ||
| }; | ||
|
|
||
| const [hoverButton, sethoverButton] = useState(); |
Contributor
There was a problem hiding this comment.
This should be in the main component body, for consistency and so that all the state variables are easily visible.
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.