Skip to content

Commit a2562b0

Browse files
committed
docs: add withMedia reference
1 parent 2f1f802 commit a2562b0

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const MyComponent = mock();
3737
- Sensors
3838
- [`<BatterySensor>`](./docs/BatterySensor.md), [`withBattery()`](./docs/BatterySensor.md#withbattery), and [`@withBattery`](./docs/BatterySensor.md#withbattery-1)
3939
- [`<MediaDeviceSensor>`](./docs/MediaDeviceSensor.md), [`withMediaDevices`](./docs/MediaDeviceSensor.md#withmediadevices), and [`@withMediaDevices`](./docs/MediaDeviceSensor.md#withmediadevices-1)
40-
- [`<MediaSensor>`](./docs/MediaSensor.md)
40+
- [`<MediaSensor>`](./docs/MediaSensor.md), [`withMedia()`](./docs/MediaSensor.md#withmedia), and [`@withMedia`](./docs/MediaSensor.md#withmedia-1)
4141
- [`<NetworkSensor>`](./docs/NetworkSensor.md) and [`withNetwork()`](./docs/NetworkSensor.md#withnetwork)
4242
- [`<LightSensor>`](./docs/LightSensor.md)
4343
- [`<LocationSensor>`](./docs/LocationSensor.md)

docs/MediaSensor.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,28 @@ import {MediaSensor} from 'libreact/lib/MediaSensor';
1111
`WIDTH IS GREATED THAN 480PX: ${matches}`
1212
}</MediaSensor>
1313
```
14+
15+
16+
## `withMedia()`
17+
18+
Higher order component that injects a boolean prop into your component that specifies if media query matches.
19+
20+
```js
21+
import {withMedia} from 'libreact/lib/MediaSensor';
22+
23+
const MyCompWithSize = withMedia(MyComp, 'isBigScreen', '(min-width: 480px)');
24+
```
25+
26+
27+
## `@withBattery`
28+
29+
Statefull component class decorator that injects a boolean prop into your component that specifies if media query matches.
30+
31+
```js
32+
import {withMedia} from 'libreact/lib/MediaSensor';
33+
34+
@withMedia('isBigScreen', '(min-width: 480px)')
35+
class MyComp extends Component {
36+
37+
}
38+
```

0 commit comments

Comments
 (0)