-
Notifications
You must be signed in to change notification settings - Fork 0
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
Basic functions #1
Conversation
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.
Well done! There are a lot of improvements, congrats 🙌
@@ -0,0 +1,151 @@ | |||
import React, {useState, useEffect} from 'react'; |
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.
To be honest, I can't go through this file, since it is more complex than the others and I'm short on time right now. It looks good to me though
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.
🚀
src/words/Letter.js
Outdated
return correct ? 'green' : 'red' | ||
} | ||
|
||
function Letter(props) { |
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.
Instead of using content
, use children
instead.
function Letter(props) {
.
.
.
return <span style={style}>
{children}
</span>
}
// call Letter
<Letter>something</Letter>
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.
how about the isCorrect
.how should it be passed?
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.
Normally via props
, you'd just fetch it from there
const { children, isCorrect, andOtherStuff } = props
@@ -0,0 +1,18 @@ | |||
import React from 'react'; |
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.
Good practice for imports
//First level npm and react modules
import React from 'react
import _ from 'lodash'
// Second level absolute imports
import { somethingUsedEverywhere } from 'utils'
// Third level local imports
import Something from "../something" // good to keep 1 maximum of back level
import AnotherSomething from "./anotherSomething"
|
||
const [keyPressed, setKeyPressed] = useState(); | ||
useEffect(() => { | ||
const downHandler = (e) => { |
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.
e
to event
for more readability
Checks if correct keys were typed
Allows user to backspace (go back if keys were pressed by mistake)