Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

stub out non-web dependencies #96

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/stack/src/utils/MaskedViewStub.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { UIManager } from 'react-native';

export { default } from '@react-native-community/masked-view';

export const isMaskedViewAvailable =
// @ts-ignore
UIManager.getViewManagerConfig('RNCMaskedView') != null;
3 changes: 3 additions & 0 deletions packages/stack/src/utils/MaskedViewStub.web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//
export default () => null;
export const isMaskedViewAvailable = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have done platform.Select in a single "utils/MaskedViewStub.ts" file except that @react-native-community/masked-view makes a call to requireNativeComponent on module initialization so it blows up on web. The component noop should never be used, but I can make it least be a passthrough <View>{children}</View> if that's preferred.

7 changes: 7 additions & 0 deletions packages/stack/src/utils/getStatusBarHeightStub.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Platform } from 'react-native';
import { getStatusBarHeight as getStatusBarHeightNative } from 'react-native-safe-area-view';

export const getStatusBarHeight = Platform.select({
default: getStatusBarHeightNative,
web: () => 0,
});
7 changes: 1 addition & 6 deletions packages/stack/src/views/Header/HeaderBackButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ import {
Platform,
StyleSheet,
LayoutChangeEvent,
UIManager,
} from 'react-native';
import Animated from 'react-native-reanimated';
import MaskedView from '@react-native-community/masked-view';
import MaskedView, { isMaskedViewAvailable } from '../../utils/MaskedViewStub';
import TouchableItem from '../TouchableItem';
import { HeaderLeftButtonProps } from '../../types';

const isMaskedViewAvailable =
// @ts-ignore
UIManager.getViewManagerConfig('RNCMaskedView') != null;

type Props = HeaderLeftButtonProps & {
tintColor: string;
};
Expand Down