-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39223 from bernhardoj/fix/22508-infinite-loading-…
…invite-page-2 Fix infinite loading on invite and task assignee page after refresh
- Loading branch information
Showing
4 changed files
with
95 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {useNavigation} from '@react-navigation/native'; | ||
import type {StackNavigationProp} from '@react-navigation/stack'; | ||
import type {ComponentType, ForwardedRef, RefAttributes} from 'react'; | ||
import React, {useEffect, useState} from 'react'; | ||
import getComponentDisplayName from '@libs/getComponentDisplayName'; | ||
import type {RootStackParamList} from '@libs/Navigation/types'; | ||
|
||
type WithNavigationTransitionEndProps = {didScreenTransitionEnd: boolean}; | ||
|
||
export default function <TProps, TRef>(WrappedComponent: ComponentType<TProps & RefAttributes<TRef>>): React.ComponentType<TProps & RefAttributes<TRef>> { | ||
function WithNavigationTransitionEnd(props: TProps, ref: ForwardedRef<TRef>) { | ||
const [didScreenTransitionEnd, setDidScreenTransitionEnd] = useState(false); | ||
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>(); | ||
|
||
useEffect(() => { | ||
const unsubscribeTransitionEnd = navigation.addListener('transitionEnd', () => { | ||
setDidScreenTransitionEnd(true); | ||
}); | ||
|
||
return unsubscribeTransitionEnd; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
return ( | ||
<WrappedComponent | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
didScreenTransitionEnd={didScreenTransitionEnd} | ||
ref={ref} | ||
/> | ||
); | ||
} | ||
|
||
WithNavigationTransitionEnd.displayName = `WithNavigationTransitionEnd(${getComponentDisplayName(WrappedComponent)})`; | ||
|
||
return React.forwardRef(WithNavigationTransitionEnd); | ||
} | ||
|
||
export type {WithNavigationTransitionEndProps}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters