Open Tketa opened 6 years ago
Thank you for the comments. Very helpful. Definitely makes more sense to pass the entire movie object to MovieCard
, not sure what I was doing there other than making life more difficult.
The refactoring is definitely helpful. In fact I tried to do this and broke the App a few times, possibly just out of fatigue. In the end I left it as it was so that it would actually work as it was nearing the deadline. You example helps. I'm going to have a go at doing it without looking at your code and if I run into trouble, use it as reference.
Hello! Thank you for submitting the first homework for CoderSchool React Class🎉 ! The main focus of this assignment was to introduce you to working with an API, rendering items in a collection, and dealing with
state
andprops
.Great✨
Components
folder. Structuring your application properly becomes increasingly important as it grows, and I feel like you got an hint about that. However coherence is important, and other folders are written in lowercase, so perhapscomponents
would have been a better name.this
inside the constructor is good practice, that's great.App.js
incomponentDidMount
. The official Facebook React Native example does this as well. (React and React Native have the same convention here.)Not so great yet 🚩
App.js
is definitely too big. What I would have done:SortableMovieList
component that handles all the sorting part. TheMoviesList
component does not have to know about the sorting, it is simply given somemovies
asprops
and its role is to display them. On the other hand doing all the sorting inApp.js
is too heavy. I tried to show you what I mean in the pull request I createdmovie
object as aprops
to theMovieCard
component. This way you just had to write<MovieCard movie={movie} />
once, and then inside theMovieCard
component you decide what to display.styles
in therender()
function, they don't need to be there (they can be declared outside of therender()
, even in a separate file even if I think it's better in the component). In general, avoid putting anything unnecessary in therender()
function (anything not dependant onprops
orstate
can go outside)