-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/mini challenge4 #3
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
base: master
Are you sure you want to change the base?
Conversation
wdonet
left a comment
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.
Revision of Acceptance Criteria
- The search term is stored and retrieved from the Global Context correctly.
- The appearance theme is stored on the Global Context and applied correctly to the App UI.
-
useReducerhook is implemented correctly to manage the Global State.
Revision of Bonus Points
- Testing coverage is above 70%. (Please include a screenshot of the code coverage report in your PR description).
- Note: It is not great but you are still over 60% - so good job so far
I was unable to see it running, but I evaluate it based on the provided code and looks pretty good. You're doing a good job so far 👌🏽 - just keep the same effort till the end. I added several suggestions, to make you think if it would be better to implement them or not.
| @@ -0,0 +1 @@ | |||
| REACT_APP_API_KEY=AIzaSyCbnwRIBvWCoQGaLIOFUx4rhLHg-Sb1a8s No newline at end of file | |||
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.
Now that you're using dotenv, this .env file is not intended to be uploaded into your repo. Otherwise the API key is still public and we want to avoid it.
You can, for example, have a .env.example file with the variables but not values like:
| REACT_APP_API_KEY=AIzaSyCbnwRIBvWCoQGaLIOFUx4rhLHg-Sb1a8s | |
| REACT_APP_API_KEY= |
Then keep .env file locally for you only. You can have it listed at the .gitignore for not allowing anyone in the team to push it into the repository accidentally.
| const isLogged = storage.get(AUTH_STORAGE_KEY); | ||
| const logIn = ( | ||
| <Link to="/login"> | ||
| <span>LogIn</span> | ||
| </Link> | ||
| ); | ||
| const logOut = <Button onClick={() => logout()}>LogOut</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.
❤️ cool - you can also move the JSX for logIn/out components to their own file and just import them here.
| <ThemeContext.Provider value={{ stateTheme, dispatchTheme }}> | ||
| <SearchWordContext.Provider value={{ state, dispatch }}> |
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.
It seems correctly coded but have a few questions for you to think about:
- Is there a specific reason for using 2 providers?
- Is it doable with a single provider?
- If so, can it be more readable for you or others?
| checked={checked} | ||
| onChange={changeHandler} | ||
| /> | ||
| <CheckBoxLabel htmlFor="checkbox" /> |
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.
I do not see where the htmlFor is consumed
|
|
||
| render(<SearchInput />); | ||
|
|
||
| fireEvent.keyDown(screen.getByRole('textbox'), { key: 'Enter' }); |
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.
❤️ cool :)
| import { fetchVideos } from './youTubeApi'; | ||
| import responseMock from '../mockData/mockData.json'; | ||
|
|
||
| describe('youTubeApi', () => { |
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.
💯 nice test
| import styled from 'styled-components'; | ||
|
|
||
| const Welcome = styled.div` | ||
| color: ${({ theme }) => theme.text}; |
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.
I've seen this pattern frenquently. You can have it extracted as a general fn as an utility to be reused at several styled component case like:
// at /util/styleUtils.js
export const getThemeField = fieldName => ({ theme }) => theme[fieldName];
export const getThemeText = getThemeField('text');
export const getThemeContent = getThemeField('content');
// Then at this line:
color: ${getThemeText};
// At the line below:
background-color: ${getThemeContent};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 the code results strange or difficult to follow, check more about currying and decide if keep it or leave it
| <ReactPlayer | ||
| width="100%" | ||
| height="80%" | ||
| url={`https://www.youtube.com/embed/${id.videoId}`} |
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.
Use a default for destructured object id, othwerwise you could get rendering errors here
| const SearchWordReducer = (state, action) => { | ||
| switch (action.type) { | ||
| case 'SET_WORD': | ||
| return { ...state, word: action.payload }; | ||
| default: | ||
| return state; | ||
| } | ||
| }; |
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.
See how payload value is hold into word at the internal state of the reducer. So you might make easier reading on your code if you give meaningful names to your variables providede to the reducer users
| const SearchWordReducer = (state, action) => { | |
| switch (action.type) { | |
| case 'SET_WORD': | |
| return { ...state, word: action.payload }; | |
| default: | |
| return state; | |
| } | |
| }; | |
| const SearchWordReducer = (state, action) => { | |
| const { type, word } = action; | |
| switch (type) { | |
| case 'SET_WORD': | |
| return { ...state, word }; | |
| default: | |
| return state; | |
| } | |
| }; |
| const ThemeReducer = (stateTheme, action) => { | ||
| switch (action.type) { | ||
| case 'SET_THEME': | ||
| return { ...stateTheme, theme: action.payload }; | ||
| default: | ||
| return stateTheme; | ||
| } | ||
| }; |
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.
Same here about naming your action content:
| const ThemeReducer = (stateTheme, action) => { | |
| switch (action.type) { | |
| case 'SET_THEME': | |
| return { ...stateTheme, theme: action.payload }; | |
| default: | |
| return stateTheme; | |
| } | |
| }; | |
| const ThemeReducer = (stateTheme, action) => { | |
| const { type, theme } = action; | |
| switch (type) { | |
| case 'SET_THEME': | |
| return { ...stateTheme, theme }; | |
| default: | |
| return stateTheme; | |
| } | |
| }; |
No description provided.