From f243584049fbf6052db5e1575b0687d4255705ff Mon Sep 17 00:00:00 2001 From: Lucas Delanier Date: Wed, 22 Feb 2023 11:58:47 +0100 Subject: [PATCH] fix display homepage --- navigation/index.tsx | 2 +- screens/HomeScreen.tsx | 159 ++++++++++++++++++----------------- screens/WatchLaterScreen.tsx | 10 +-- 3 files changed, 86 insertions(+), 85 deletions(-) diff --git a/navigation/index.tsx b/navigation/index.tsx index 1f31fe0..143056d 100644 --- a/navigation/index.tsx +++ b/navigation/index.tsx @@ -61,7 +61,7 @@ function BottomTabNavigator() { return ( ) }); - const dispatch = useDispatch(); - + useEffect(() => { + const loadTrendingID = async () => { + // @ts-ignore + await dispatch(getTrendingID()); + }; + console.log("test1:", trendingMovies); + loadTrendingID(); + }, [dispatch]); type ItemProps = { movie : Movie @@ -88,80 +94,83 @@ export default function HomeScreen({ navigation }: RootStackScreenProps<'Home'>) dispatch(removeMovieTrending(props)); } -return( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {trendingMovies[0].original_title} - - {trendingMovies[0].release_date} - - - addWatchLater(trendingMovies[0])}> - - - + return( + <> + {trendingMovies.length !== 0 && ( + + + - - - - - - - - ); - + + + + + + + + + + + + + + + + + + + + + + + + + + {trendingMovies[0].original_title} + + {trendingMovies[0].release_date} + + + addWatchLater(trendingMovies[0])}> + + + + + + + + + + + + )} + +) } type BadgeGenreProps = { name : String @@ -170,7 +179,7 @@ type BadgeGenreProps = { } export function BadgeGenre(props: BadgeGenreProps) { - if(props.isSelected==false){ + if(props.isSelected===false){ return ( {props.name} diff --git a/screens/WatchLaterScreen.tsx b/screens/WatchLaterScreen.tsx index d98010f..dc28830 100644 --- a/screens/WatchLaterScreen.tsx +++ b/screens/WatchLaterScreen.tsx @@ -42,15 +42,7 @@ export default function WatchLaterScreen({ navigation }: RootTabScreenProps<'Wat const [isLoading, setLoading] = useState(true); // @ts-ignore const trendingMovies = useSelector(state => state.appReducer.watchLaterMovies); - const dispatch = useDispatch(); - useEffect(() => { - const loadTrendingID = async () => { - // @ts-ignore - await dispatch(getTrendingID()); - }; - loadTrendingID(); - console.log("test2:", trendingMovies); - }, [dispatch]); + return (