Home button scrolls to top when on home page

This commit is contained in:
Paul Frazee 2022-10-11 09:37:01 -05:00
parent 8dc8200f07
commit d7a75a2062
5 changed files with 29 additions and 16 deletions

View file

@ -1,4 +1,4 @@
import React from 'react'
import React, {MutableRefObject} from 'react'
import {observer} from 'mobx-react-lite'
import {Text, View, FlatList, StyleProp, ViewStyle} from 'react-native'
import {FeedModel, FeedItemModel} from '../../../state/models/feed-view'
@ -7,9 +7,11 @@ import {FeedItem} from './FeedItem'
export const Feed = observer(function Feed({
feed,
style,
scrollElRef,
}: {
feed: FeedModel
style?: StyleProp<ViewStyle>
scrollElRef?: MutableRefObject<FlatList<any> | null>
}) {
// TODO optimize renderItem or FeedItem, we're getting this notice from RN: -prf
// VirtualizedList: You have a large list that is slow to update - make sure your
@ -30,6 +32,7 @@ export const Feed = observer(function Feed({
{feed.hasError && <Text>{feed.error}</Text>}
{feed.hasContent && (
<FlatList
ref={scrollElRef}
data={feed.feed.slice()}
keyExtractor={item => item._reactKey}
renderItem={renderItem}