diff --git a/src/components/AvatarList/index.tsx b/src/components/AvatarList/index.tsx index 7b79f8c..1dad709 100644 --- a/src/components/AvatarList/index.tsx +++ b/src/components/AvatarList/index.tsx @@ -4,6 +4,19 @@ import StoryAvatar from '../Avatar'; import { StoryAvatarListProps } from '~/core/dto/componentsDTO'; import { InstagramStoryProps } from '~/core/dto/instagramStoriesDTO'; +let FlashList: any; + +try { + + // eslint-disable-next-line global-require + FlashList = require( '@shopify/flash-list' ).FlashList; + +} catch ( error ) { + + FlashList = null; + +} + const StoryAvatarList: FC = ( { stories, loadingStory, seenStories, colors, seenColors, size, showName, nameTextStyle, nameTextProps, listContainerProps, listContainerStyle, @@ -27,10 +40,7 @@ const StoryAvatarList: FC = ( { /> ) ); - try { - - // eslint-disable-next-line global-require - const { FlashList } = require( '@shopify/flash-list' ); + if ( FlashList ) { return ( = ( { /> ); - } catch ( error ) { - - return ( - - {stories.map( renderItem )} - - ); - } + return ( + + {stories.map( renderItem )} + + ); + }; export default memo( StoryAvatarList ); diff --git a/src/core/constants/index.ts b/src/core/constants/index.ts index 4ea5850..d36284d 100644 --- a/src/core/constants/index.ts +++ b/src/core/constants/index.ts @@ -1,6 +1,6 @@ import { Dimensions } from 'react-native'; -export const { width: WIDTH, height: HEIGHT } = Dimensions.get( 'window' ); +export const { width: WIDTH, height: HEIGHT } = Dimensions.get( 'screen' ); export const STORAGE_KEY = '@birdwingo/react-native-instagram-stories';