Skip to content

Commit

Permalink
chore(wallet-mobile): wiring up
Browse files Browse the repository at this point in the history
  • Loading branch information
stackchain committed May 3, 2024
1 parent a2f8f13 commit c4af1bd
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions apps/wallet-mobile/src/TxHistory/TxHistoryList/TxHistoryList.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {useFocusEffect, useNavigation} from '@react-navigation/native'
import {useFocusEffect} from '@react-navigation/native'
import {isString} from '@yoroi/common'
import {useTheme} from '@yoroi/theme'
import _ from 'lodash'
import React from 'react'
import {useIntl} from 'react-intl'
import {Platform, SectionList, SectionListProps, StyleSheet, View} from 'react-native'
import {SectionList, SectionListProps, StyleSheet, View} from 'react-native'

import {Spacer, Text} from '../../components'
import {ShowBuyBanner} from '../../features/Exchange/common/ShowBuyBanner/ShowBuyBanner'
Expand All @@ -20,9 +20,8 @@ type ListProps = SectionListProps<TransactionInfo>
type Props = Partial<ListProps> & {
onScroll: ListProps['onScroll']
}
export const TxHistoryList = (props: Props) => {
export const TxHistoryList = React.memo((props: Props) => {
const styles = useStyles()
const key = useRemountOnFocusHack()
const wallet = useSelectedWallet()
const {track} = useMetrics()

Expand All @@ -39,7 +38,6 @@ export const TxHistoryList = (props: Props) => {
<View style={styles.container}>
<SectionList
{...props}
key={key}
ListHeaderComponent={<ShowBuyBanner />}
contentContainerStyle={styles.content}
renderItem={({item}) => <TxHistoryListItem transaction={item} />}
Expand All @@ -56,28 +54,7 @@ export const TxHistoryList = (props: Props) => {
/>
</View>
)
}

// workaround for https://emurgo.atlassian.net/browse/YOMO-199
// related to https://github.com/facebook/react-native/issues/15694
export const useRemountOnFocusHack = () => {
const [key, setKey] = React.useState(0)
const navigation = useNavigation()

React.useEffect(() => {
if (Platform.OS !== 'ios') {
return
}

const unsubscribe = navigation.addListener('focus', () => {
setKey((key) => key + 1)
})

return unsubscribe
}, [key, navigation])

return key
}
})

type DayHeaderProps = {
ts: unknown
Expand Down

0 comments on commit c4af1bd

Please sign in to comment.