This repository has been archived by the owner on Feb 8, 2020. It is now read-only.
generated from satya164/typescript-template
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: workaround SafereaProvider causing jumping
see #174
- Loading branch information
Showing
6 changed files
with
88 additions
and
13 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
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,26 @@ | ||
import * as React from 'react'; | ||
import { | ||
SafeAreaProvider, | ||
SafeAreaConsumer, | ||
} from 'react-native-safe-area-context'; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
export default function SafeAreaProviderCompat({ children }: Props) { | ||
return ( | ||
<SafeAreaConsumer> | ||
{insets => { | ||
if (insets) { | ||
// If we already have insets, don't wrap the stack in another safe area provider | ||
// This avoids an issue with updates at the cost of potentially incorrect values | ||
// https://github.com/react-navigation/navigation-ex/issues/174 | ||
return children; | ||
} | ||
|
||
return <SafeAreaProvider>{children}</SafeAreaProvider>; | ||
}} | ||
</SafeAreaConsumer> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as React from 'react'; | ||
import { | ||
SafeAreaProvider, | ||
SafeAreaConsumer, | ||
} from 'react-native-safe-area-context'; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
export default function SafeAreaProviderCompat({ children }: Props) { | ||
return ( | ||
<SafeAreaConsumer> | ||
{insets => { | ||
if (insets) { | ||
// If we already have insets, don't wrap the stack in another safe area provider | ||
// This avoids an issue with updates at the cost of potentially incorrect values | ||
// https://github.com/react-navigation/navigation-ex/issues/174 | ||
return children; | ||
} | ||
|
||
return <SafeAreaProvider>{children}</SafeAreaProvider>; | ||
}} | ||
</SafeAreaConsumer> | ||
); | ||
} |
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,26 @@ | ||
import * as React from 'react'; | ||
import { | ||
SafeAreaProvider, | ||
SafeAreaConsumer, | ||
} from 'react-native-safe-area-context'; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
export default function SafeAreaProviderCompat({ children }: Props) { | ||
return ( | ||
<SafeAreaConsumer> | ||
{insets => { | ||
if (insets) { | ||
// If we already have insets, don't wrap the stack in another safe area provider | ||
// This avoids an issue with updates at the cost of potentially incorrect values | ||
// https://github.com/react-navigation/navigation-ex/issues/174 | ||
return children; | ||
} | ||
|
||
return <SafeAreaProvider>{children}</SafeAreaProvider>; | ||
}} | ||
</SafeAreaConsumer> | ||
); | ||
} |
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
c17ad18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Gonna try to look at this next week