Skip to content
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

Merged
merged 11 commits into from
Sep 4, 2020
Merged

Basic functions #1

merged 11 commits into from
Sep 4, 2020

Conversation

victorpre
Copy link
Owner

Checks if correct keys were typed
Allows user to backspace (go back if keys were pressed by mistake)

Copy link

@ubmit ubmit left a 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 🙌

src/words/Word.js Outdated Show resolved Hide resolved
src/hooks/useKeyPress.js Show resolved Hide resolved
src/utils/loader.js Outdated Show resolved Hide resolved
src/words/Letter.js Outdated Show resolved Hide resolved
@@ -0,0 +1,151 @@
import React, {useState, useEffect} from 'react';
Copy link

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

Copy link

@alecarneiro1993 alecarneiro1993 left a 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 Show resolved Hide resolved
return correct ? 'green' : 'red'
}

function Letter(props) {

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>

Copy link
Owner Author

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?

Copy link

@alecarneiro1993 alecarneiro1993 Sep 4, 2020

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';

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"
 

src/words/Word.js Outdated Show resolved Hide resolved
src/words/Words.js Outdated Show resolved Hide resolved

const [keyPressed, setKeyPressed] = useState();
useEffect(() => {
const downHandler = (e) => {

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

src/hooks/useKeyPress.js Outdated Show resolved Hide resolved
src/words/Words.js Outdated Show resolved Hide resolved
src/words/Words.js Show resolved Hide resolved
src/words/Words.js Outdated Show resolved Hide resolved
@victorpre victorpre merged commit d81982c into master Sep 4, 2020
@victorpre victorpre deleted the basic-functions branch September 4, 2020 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants