Skip to content

Conversation

@JaviHuizar
Copy link

Adding:

  1. Search term in global context.
  2. Global theme
  3. useReducer for search term
  4. Adding Fetch API

Copy link

@erickwize erickwize left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left out some comments, good work.
I also saw that sometimes when you click some videos this happens:
image

@@ -0,0 +1 @@
REACT_APP_API_YOUTUBE_KEY = AIzaSyAOsyZMq5msH04OZ9W7Y_fQX--TictP_v8 No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend to not keep track of this file, it is a good practice to create a .env file but also not keeping track of this file.

import LocalThemeProvider from '../../state/ThemeContext.provider';

function App() {
// const [search, setSearch] = useState('Wizeline');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend removing all commented code so it won't be kept commented in the future.

Comment on lines +6 to +11
const NavBarStyled = styled.div`
background-color: ${(props) => props.theme.primary};
display: flex;
align-items: center;
justify-content: space-between;
`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend taking out the style from the logic of the components

<div>
<LocalThemeProvider>
<SearchContext.Provider value={{ state, dispatch }}>
<NavBar search={handleSearch} />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use the context inside the NavBar itself instead of creating a function and then send it to the component. The prop drilling is not being removed even with the usage of a Context. One of the usages of the context is to remove prop drilling

justify-content: space-between;
`;

function NavBar({ search }) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also recommend using the context hook to obtain the search value instead of using prop drilling to obtain the value.

text-align: center;
`;

export default function VideoList({ videos, handleVideoSelected }) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using prop drilling with handleVideoSelected use the context API from react

/>
);
});
return <VideoListContainer>{renderedVideos}</VideoListContainer>;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also recommend putting the map itself inside the video.map(...)

const renderedVideos = videos.map((video) => {
return (
<VideoCard
key={Math.random()}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And instead of using a Math.random() you could use something unique from the video. i.e. the etag from the video or the title itself. It is not a good practice because every re-render the Math.random() would change and the key performance won't work.

Comment on lines +13 to +16
.then((response) => response.data)
.catch((error) => {
console.log(error);
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend not combining async/await and promises in the same block, you should try to get the information using all async/await or using only promises.

Comment on lines +8 to +28
const HomeBody = styled.div`
background-color: #1a243b;
text-align: center;
display: flex;
`;
const VideoRelatedWrap = styled.div`
text-align: center;
flex: 3;
margin-top: 100px;
`;
const H4 = styled.h4`
color: #b9b1b1;
`;
const VideoListWrap = styled.div`
text-align: center;
flex: 4;
`;
const VideoDetailWrap = styled.div`
text-align: center;
flex: 5;
`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract CSS style from the component

Copy link

@erickwize erickwize left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments

I left out some comments, good work. I also recommend creating the PR into your own github repo, not into the base one.
I also saw that sometimes when you click some videos this happens:
image

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.
  • useReducer hook is implemented correctly to manage the Global State.

Bonus Points

  • Testing coverage is above 70%. (Please include a screenshot of the code coverage report in your PR description).

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.

2 participants