Skip to content

Commit

Permalink
feat: Upgrade safe-area-context to 1.0
Browse files Browse the repository at this point in the history
BREAKING CHANGE: SafeAreaContext was renamed to SafeAreaInsetsContext.
See
https://github.com/th3rdwave/react-native-safe-area-context/releases/tag/1.0.0

Continue exporting deprecated `useSafeArea` and `SafeAreaConsumer`
  • Loading branch information
davidgovea committed May 11, 2020
1 parent 93aa546 commit f180e95
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"react-native": "~0.61.5",
"react-native-gesture-handler": "~1.6.0",
"react-native-reanimated": "~1.7.0",
"react-native-safe-area-context": "0.7.3",
"react-native-safe-area-context": "^1.0.0",
"react-native-safe-area-view": "^0.14.7",
"react-native-screens": "~2.2.0",
"react-native-unimodules": "~0.9.0",
Expand Down
8 changes: 4 additions & 4 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6438,10 +6438,10 @@ react-native-reanimated@~1.7.0:
dependencies:
fbjs "^1.0.0"

react-native-safe-area-context@0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-0.7.3.tgz#ad6bd4abbabe195332c53810e4ce5851eb21aa2a"
integrity sha512-9Uqu1vlXPi+2cKW/CW6OnHxA76mWC4kF3wvlqzq4DY8hn37AeiXtLFs2WkxH4yXQRrnJdP6ivc65Lz+MqwRZAA==
react-native-safe-area-context@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-1.0.0.tgz#8b4d79b06d6a9ed5ff3b2c3f0ba25d85538a3149"
integrity sha512-8Poo0FHSS/KE0fP6JUH9Mnjg2KQ5MfZAJN3G8/gW2HoFSypWSfFmDp5msETU0Ix3OnRsmBZTJpmgHFEl9OfNAg==

react-native-safe-area-view@^0.14.7:
version "0.14.9"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"peerDependencies": {
"react": "*",
"react-native": "*",
"react-native-safe-area-context": "*"
"react-native-safe-area-context": ">=1.0.0"
},
"devDependencies": {
"@babel/core": "^7",
Expand All @@ -59,7 +59,7 @@
"prettier": "^1.18.2",
"react": "16.8.3",
"react-native": "~0.61.4",
"react-native-safe-area-context": "0.7.3",
"react-native-safe-area-context": "^1.0.0",
"typescript": "^3.8.3"
}
}
18 changes: 13 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,24 @@ import {
} from 'react-native';
import {
EdgeInsets,
SafeAreaContext,
SafeAreaProvider,
SafeAreaConsumer,
SafeAreaInsetsContext,
SafeAreaProvider,
useSafeArea,
useSafeAreaInsets,
} from 'react-native-safe-area-context';

import shallowEquals from './shallowEquals';

// Re-export react-native-safe-area-context utilities
export { useSafeArea, SafeAreaProvider, SafeAreaConsumer, SafeAreaContext };
export {
useSafeAreaInsets,
SafeAreaProvider,
SafeAreaInsetsContext,
// Deprecated:
useSafeArea,
SafeAreaConsumer,
};

export type ForceInsetValue = 'always' | 'never';
export type ForceInsetProp = {
Expand Down Expand Up @@ -53,8 +61,8 @@ interface AnimatedView extends Animated.AnimatedComponent<View> {
}

export default class SafeAreaView extends React.Component<Props, State> {
static contextType: any = SafeAreaContext;
context!: React.ContextType<typeof SafeAreaContext>;
static contextType: any = SafeAreaInsetsContext;
context!: React.ContextType<typeof SafeAreaInsetsContext>;
private _isMounted: boolean = false;
private _view = React.createRef<AnimatedView>();

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3934,10 +3934,10 @@ react-is@^16.8.1:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.9.0.tgz#21ca9561399aad0ff1a7701c01683e8ca981edcb"
integrity sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw==

react-native-safe-area-context@0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-0.7.3.tgz#ad6bd4abbabe195332c53810e4ce5851eb21aa2a"
integrity sha512-9Uqu1vlXPi+2cKW/CW6OnHxA76mWC4kF3wvlqzq4DY8hn37AeiXtLFs2WkxH4yXQRrnJdP6ivc65Lz+MqwRZAA==
react-native-safe-area-context@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-1.0.0.tgz#8b4d79b06d6a9ed5ff3b2c3f0ba25d85538a3149"
integrity sha512-8Poo0FHSS/KE0fP6JUH9Mnjg2KQ5MfZAJN3G8/gW2HoFSypWSfFmDp5msETU0Ix3OnRsmBZTJpmgHFEl9OfNAg==

react-native@~0.61.4:
version "0.61.5"
Expand Down

0 comments on commit f180e95

Please sign in to comment.