Skip to content

Commit 2cd5f3a

Browse files
committed
feat: add withOrientation() HOC
1 parent f0808f5 commit 2cd5f3a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/OrientationSensor/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {Component, createElement as h} from 'react';
1+
import {Component} from 'react';
22
import {SyncSensor} from '../SyncSensor';
3-
import {on, off, isClient} from '../util';
3+
import {h, on, off, isClient} from '../util';
44

55
export interface IOrientationSensorProps {
66
children?: (state: IOrientationSensorState) => React.ReactElement<any>;
@@ -53,3 +53,12 @@ export class OrientationSensor extends Component<IOrientationSensorProps, any> {
5353
});
5454
}
5555
}
56+
57+
export const withOrientation = (Comp) =>
58+
(props) =>
59+
h(OrientationSensor, null, (orientation) =>
60+
h(Comp, {
61+
...props,
62+
orientation
63+
})
64+
);

0 commit comments

Comments
 (0)