@@ -66,23 +66,42 @@ export default class Login extends Component {
66
66
| condition | boolean | Abritrary boolean value that must be true for the media query to pass. |
67
67
68
68
69
- ### ResponsiveComponent
69
+ ### Responsive Annotation
70
70
71
- ` ResponsiveComponents ` extends ` React.Component ` and add the window dimensions to the state of the component.
71
+ You can use es7 annotation in order to listen for dimension changes in a React component.
72
72
73
73
``` jsx
74
74
import React from " react" ;
75
- import {ResponsiveComponent } from " react-native-responsive-ui" ;
75
+ import {responsive } from " react-native-responsive-ui" ;
76
76
77
- export default class Debug extends ResponsiveComponent {
77
+ @responsive
78
+ export default class Debug extends React .Component {
79
+ render () {
80
+ const {width , height } = this .state .window ;
81
+ console .log (` New window dimensions: ${ width} x${ height} ` );
82
+ return null ;
83
+ }
84
+ }
85
+ ```
86
+
87
+ Or without the decorator syntax:
88
+
89
+ ``` jsx
90
+ import React from " react" ;
91
+ import {responsive } from " react-native-responsive-ui" ;
92
+
93
+ class Debug extends React .Component {
78
94
render () {
79
95
const {width , height } = this .state .window ;
80
96
console .log (` New window dimensions: ${ width} x${ height} ` );
81
97
return null ;
82
98
}
83
99
}
100
+
101
+ export default responsive (Debug);
84
102
```
85
103
104
+
86
105
### ResponsiveStyleSheet
87
106
88
107
` ResponsiveStyleSheet ` returns a stylesheet given multiple media queries.
@@ -143,3 +162,21 @@ import {Device, MediaQuerySelector} from "react-native-responsive-ui";
143
162
const {width , height } = Device .dimensions .window ;
144
163
MediaQuerySelector .query ({ orientation: " portrait" , minHeight: 450 }, width, height)
145
164
```
165
+
166
+
167
+ ### ResponsiveComponent
168
+
169
+ ` ResponsiveComponents ` extends ` React.Component ` and add the window dimensions to the state of the component.
170
+
171
+ ``` jsx
172
+ import React from " react" ;
173
+ import {ResponsiveComponent } from " react-native-responsive-ui" ;
174
+
175
+ export default class Debug extends ResponsiveComponent {
176
+ render () {
177
+ const {width , height } = this .state .window ;
178
+ console .log (` New window dimensions: ${ width} x${ height} ` );
179
+ return null ;
180
+ }
181
+ }
182
+ ```
0 commit comments