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