Skip to content

Commit

Permalink
bug: trigger connectAnimatedNodes crash
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterds committed Jul 5, 2023
1 parent ff72145 commit 5091d06
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
17 changes: 15 additions & 2 deletions src/components/Swimlane/PopularMovies/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { memo } from 'react';
import React, { memo, useEffect, useState } from 'react';
import { FlatList, Text, TVFocusGuideView, View } from 'react-native';
import { usePopularMovies } from 'store/popular-movies/hooks';

Expand All @@ -14,6 +14,15 @@ const PopularMoviesSwimlane = ({ hideTitle }: Props) => {
fetch: true,
});

const [forceShimmers, setForceShimmers] = useState(false);
useEffect(() => {
const timeout = setTimeout(() => {
setForceShimmers(!forceShimmers);
}, Math.random() * 5000 + 2000);

return () => clearTimeout(timeout);
}, [forceShimmers]);

if (isEmpty) {
// render empty state?
return null;
Expand All @@ -33,7 +42,11 @@ const PopularMoviesSwimlane = ({ hideTitle }: Props) => {
horizontal={true}
showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false}
data={isLoading && data.length === 0 ? new Array(6).fill(null) : data}
data={
forceShimmers || (isLoading && data.length === 0)
? new Array(6).fill(null)
: data
}
renderItem={({ item }) => <Item id={item?.id} />}
/>
</TVFocusGuideView>
Expand Down
17 changes: 15 additions & 2 deletions src/components/Swimlane/PopularTVShows/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { memo } from 'react';
import React, { memo, useEffect, useState } from 'react';
import { FlatList, Text, TVFocusGuideView, View } from 'react-native';
import { usePopularTVShows } from 'store/popular-tv-shows/hooks';

Expand All @@ -14,6 +14,15 @@ const PopularTVShowsSwimlane = ({ hideTitle }: Props) => {
fetch: true,
});

const [forceShimmers, setForceShimmers] = useState(false);
useEffect(() => {
const timeout = setTimeout(() => {
setForceShimmers(!forceShimmers);
}, Math.random() * 5000 + 2000);

return () => clearTimeout(timeout);
}, [forceShimmers]);

if (isEmpty) {
// render empty state?
return null;
Expand All @@ -33,7 +42,11 @@ const PopularTVShowsSwimlane = ({ hideTitle }: Props) => {
horizontal={true}
showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false}
data={isLoading && data.length === 0 ? new Array(6).fill(null) : data}
data={
forceShimmers || (isLoading && data.length === 0)
? new Array(6).fill(null)
: data
}
renderItem={({ item }) => <Item id={item?.id} />}
/>
</TVFocusGuideView>
Expand Down
14 changes: 13 additions & 1 deletion src/screens/Discover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,19 @@ const DiscoverScreen = () => {
<Banner.UpcomingMovies />
<Swimlane.TopRatedTVShows />
<Swimlane.TopRatedMovies />
{/* <Swimlane.PopularTVShows /> */}
<Swimlane.PopularTVShows />
<Swimlane.TrendingToday />
<Swimlane.PopularTVShows />
<Swimlane.PopularMovies />
<Swimlane.TrendingToday />
<Swimlane.PopularTVShows />
<Swimlane.PopularMovies />
<Swimlane.TrendingToday />
<Swimlane.PopularTVShows />
<Swimlane.PopularMovies />
<Swimlane.TrendingToday />
<Swimlane.PopularTVShows />
<Swimlane.PopularMovies />
</ScreenWrapper>
);
};
Expand Down

0 comments on commit 5091d06

Please sign in to comment.