-
-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow web's SafeAreaView to forward ref to its underlying view (#383)
* feat: allow web's SafeAreaView to forward ref * refactor: remove unnecessary return type * refactor: remove return type for SafeAreaView
- Loading branch information
1 parent
207d894
commit ceb5e57
Showing
3 changed files
with
34 additions
and
27 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 |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import * as React from 'react'; | ||
import type { NativeSafeAreaViewProps } from './SafeArea.types'; | ||
import type { | ||
NativeSafeAreaViewInstance, | ||
NativeSafeAreaViewProps, | ||
} from './SafeArea.types'; | ||
import NativeSafeAreaView from './specs/NativeSafeAreaView'; | ||
|
||
type NativeSafeAreaViewInstance = InstanceType<typeof NativeSafeAreaView>; | ||
|
||
export type SafeAreaViewProps = NativeSafeAreaViewProps; | ||
|
||
export const SafeAreaView: React.ForwardRefExoticComponent< | ||
SafeAreaViewProps & React.RefAttributes<NativeSafeAreaViewInstance> | ||
> = React.forwardRef<NativeSafeAreaViewInstance, SafeAreaViewProps>( | ||
({ edges, ...props }, ref) => { | ||
return ( | ||
<NativeSafeAreaView | ||
{...props} | ||
// Codegen doesn't support default values for array types so | ||
// set it here. | ||
edges={edges ?? ['bottom', 'left', 'right', 'top']} | ||
ref={ref} | ||
/> | ||
); | ||
}, | ||
); | ||
export const SafeAreaView = React.forwardRef< | ||
NativeSafeAreaViewInstance, | ||
SafeAreaViewProps | ||
>(({ edges, ...props }, ref) => { | ||
return ( | ||
<NativeSafeAreaView | ||
{...props} | ||
// Codegen doesn't support default values for array types so | ||
// set it here. | ||
edges={edges ?? ['bottom', 'left', 'right', 'top']} | ||
ref={ref} | ||
/> | ||
); | ||
}); |
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