Skip to content

Commit

Permalink
fix(test): _NativeSafeAreaContext.default.getConstants is not a funct…
Browse files Browse the repository at this point in the history
…ion (#335)

Fixes #290 
Fixes #255 

Verified to work in our own projects. The reason is described in #290, it appears that the native module import comes back as `{ default: {} }`. So `default.getConstants` is `undefined`. The fix ensures it's only called if defined.
  • Loading branch information
andreialecu authored Jan 19, 2023
1 parent fd4c27c commit d424f12
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/InitialWindow.native.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Metrics } from './SafeArea.types';
import NativeSafeAreaContext from './specs/NativeSafeAreaContext';

export const initialWindowMetrics = (NativeSafeAreaContext?.getConstants()
export const initialWindowMetrics = (NativeSafeAreaContext?.getConstants?.()
?.initialWindowMetrics ?? null) as Metrics | null;

/**
Expand Down

0 comments on commit d424f12

Please sign in to comment.