Hey Faraz,
great Impressions for a React Newbi :) Thanks for your six parts, hope more comming soon. The Enumeration of Status is a great idea. I've used 3 booleans for checking state of loading and showing a message :)
But i have a question about how you query your MovieService. This looks pretty awesome how you call your functions:
MovieService
.fetchInitialMovies()
.then(initialMovies => setMovies(initialMovies))
.then(() => setIsLoading(false))
Can you show me how your MovieService works? Haven't found any code of your MovieService :(
I'm a software engineer with a lot of React and startup experience. I write about my opinions on React, using Firebase with React, and lessons from building my 1st startup, Retro.
Hey! Sure. I made a mock service just for learning purposes. I have some hard-coded values that I return using a setTimeout and a Promise.
Here it is:
import{Movie}from"../types/movie";constMOVIES:Movie[]=[{id:1,title:"Iron Man"},{id:2,title:"The Incredible Hulk"},{id:3,title:"Iron Man 2"},{id:4,title:"Thor"},{id:5,title:"Captain America: The First Avenger"},{id:6,title:"The Avengers"}];exportclassMovieService{staticfetchMovieTitles():Promise<Movie[]>{returnnewPromise(resolve=>{returnsetTimeout(()=>resolve(MOVIES),2000);});}}
What this does is returns a list of movies after 2000ms.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey Faraz,
great Impressions for a React Newbi :) Thanks for your six parts, hope more comming soon. The Enumeration of Status is a great idea. I've used 3 booleans for checking state of loading and showing a message :)
But i have a question about how you query your MovieService. This looks pretty awesome how you call your functions:
MovieService
.fetchInitialMovies()
.then(initialMovies => setMovies(initialMovies))
.then(() => setIsLoading(false))
Can you show me how your MovieService works? Haven't found any code of your MovieService :(
Thanks :)
Hey! Sure. I made a mock service just for learning purposes. I have some hard-coded values that I return using a
setTimeout
and aPromise
.Here it is:
What this does is returns a list of movies after 2000ms.