Bladeren bron
Add withSafeAreaConsumer HOC (#57)
* Add withSafeAreaConsumer HOC
It's a good option to inject the insets of SafeAreaConsumer as props from React class components
* Fix prettier issues
Juan David Nicholls Cardona
4 jaren geleden
bovenliggende
commit
79ab4dd028
No account linked to committer's email address
|
@@ -106,3 +106,13 @@ export function SafeAreaConsumer(
|
106
|
106
|
) {
|
107
|
107
|
return <SafeAreaInsetsContext.Consumer {...props} />;
|
108
|
108
|
}
|
|
109
|
+
|
|
110
|
+export function withSafeAreaInsets<T>(
|
|
111
|
+ WrappedComponent: React.ComponentType<T>,
|
|
112
|
+) {
|
|
113
|
+ return (props: T) => (
|
|
114
|
+ <SafeAreaConsumer>
|
|
115
|
+ {insets => <WrappedComponent {...props} insets={insets} />}
|
|
116
|
+ </SafeAreaConsumer>
|
|
117
|
+ );
|
|
118
|
+}
|