Chore: Deprecate Dimensions (#4597)
This commit is contained in:
parent
1486204546
commit
1aef030d75
|
@ -26,6 +26,9 @@ export const DimensionsContext = React.createContext<IDimensionsContextProps>(
|
|||
Dimensions.get('window') as IDimensionsContextProps
|
||||
);
|
||||
|
||||
/**
|
||||
* @deprecated use RN's useWindowDimensions hook instead
|
||||
*/
|
||||
export function withDimensions<T extends object>(Component: React.ComponentType<T> & TNavigationOptions): typeof Component {
|
||||
const DimensionsComponent = (props: T) => (
|
||||
<DimensionsContext.Consumer>{contexts => <Component {...props} {...contexts} />}</DimensionsContext.Consumer>
|
||||
|
@ -35,8 +38,14 @@ export function withDimensions<T extends object>(Component: React.ComponentType<
|
|||
return DimensionsComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use RN's useWindowDimensions hook instead
|
||||
*/
|
||||
export const useDimensions = () => React.useContext(DimensionsContext);
|
||||
|
||||
/**
|
||||
* @deprecated use RN's useWindowDimensions hook instead
|
||||
*/
|
||||
export const useOrientation = () => {
|
||||
const { width, height } = React.useContext(DimensionsContext);
|
||||
const isPortrait = height > width;
|
||||
|
|
Loading…
Reference in New Issue