浏览代码

[RN] Fix eslint & flow errors

j8
Lyubo Marinov 8 年前
父节点
当前提交
bce2a9fba9

+ 48
- 39
react/features/base/aspect-ratio/components/AspectRatioAware.js 查看文件

@@ -1,42 +1,64 @@
1 1
 // @flow
2
+
2 3
 import PropTypes from 'prop-types';
3 4
 import React, { Component } from 'react';
4 5
 import { connect } from 'react-redux';
5 6
 
6
-import { ASPECT_RATIO_NARROW } from '../constants';
7
+import { ASPECT_RATIO_NARROW, ASPECT_RATIO_WIDE } from '../constants';
8
+
9
+/**
10
+ * Checks if given React component decorated in {@link AspectRatioAwareWrapper}
11
+ * has currently the {@link ASPECT_RATIO_NARROW} set in the aspect ratio
12
+ * property.
13
+ *
14
+ * @param {AspectRatioAwareWrapper} component - A
15
+ * {@link AspectRatioAwareWrapper} which has <tt>aspectRation</tt> property.
16
+ * @returns {boolean}
17
+ */
18
+export function isNarrowAspectRatio(component: React$Component<*>) {
19
+    return component.props.aspectRatio === ASPECT_RATIO_NARROW;
20
+}
7 21
 
8 22
 /**
9
- * Decorates given React component class into {@link AspectRatioAwareWrapper}
10
- * which provides the <tt>aspectRatio</tt> property updated on each Redux state
11
- * change.
23
+ * Decorates a specific React {@code Component} class into an
24
+ * {@link AspectRatioAware} which provides the React prop {@code aspectRatio}
25
+ * updated on each redux state change.
12 26
  *
13
- * @param {ReactClass} WrapperComponent - A React component class to be wrapped.
27
+ * @param {Class<React$Component>} WrappedComponent - A React {@code Component}
28
+ * class to be wrapped.
14 29
  * @returns {AspectRatioAwareWrapper}
15 30
  */
16
-export function AspectRatioAware(
17
-        WrapperComponent: ReactClass<*>): ReactClass<*> {
18
-    return connect(_mapStateToProps)(
19
-        class AspectRatioAwareWrapper extends Component {
31
+export function makeAspectRatioAware(
32
+        WrappedComponent: Class<React$Component<*>>
33
+): Class<React$Component<*>> {
34
+    /**
35
+     * Renders {@code WrappedComponent} with the React prop {@code aspectRatio}.
36
+     */
37
+    class AspectRatioAware extends Component<*> {
38
+        /**
39
+         * Properties of the aspect ratio aware wrapper.
40
+         */
41
+        static propTypes = {
20 42
             /**
21
-             * Properties of the aspect ratio aware wrapper.
43
+             * Either {@link ASPECT_RATIO_NARROW} or {@link ASPECT_RATIO_WIDE}.
22 44
              */
23
-            static propTypes = {
24
-                /**
25
-                 * Either {@link ASPECT_RATIO_NARROW} or
26
-                 * {@link ASPECT_RATIO_WIDE}.
27
-                 */
28
-                aspectRatio: PropTypes.symbol
29
-            }
45
+            aspectRatio: PropTypes.oneOf([
46
+                ASPECT_RATIO_NARROW,
47
+                ASPECT_RATIO_WIDE
48
+            ])
49
+        }
30 50
 
31
-            /**
32
-             * Implement's React render method to wrap the nested component.
33
-             *
34
-             * @returns {XML}
35
-             */
36
-            render(): React$Element<*> {
37
-                return <WrapperComponent { ...this.props } />;
38
-            }
39
-        });
51
+        /**
52
+         * Implement's React render method to wrap the nested component.
53
+         *
54
+         * @returns {React$Element}
55
+         */
56
+        render(): React$Element<*> {
57
+            return <WrappedComponent { ...this.props } />;
58
+        }
59
+    }
60
+
61
+    return connect(_mapStateToProps)(AspectRatioAware);
40 62
 }
41 63
 
42 64
 /**
@@ -53,16 +75,3 @@ function _mapStateToProps(state) {
53 75
         aspectRatio: state['features/base/aspect-ratio'].aspectRatio
54 76
     };
55 77
 }
56
-
57
-/**
58
- * Checks if given React component decorated in {@link AspectRatioAwareWrapper}
59
- * has currently the {@link ASPECT_RATIO_NARROW} set in the aspect ratio
60
- * property.
61
- *
62
- * @param {AspectRatioAwareWrapper} component - A
63
- * {@link AspectRatioAwareWrapper} which has <tt>aspectRation</tt> property.
64
- * @returns {boolean}
65
- */
66
-export function isNarrowAspectRatio(component: ReactClass<*>) {
67
-    return component.props.aspectRatio === ASPECT_RATIO_NARROW;
68
-}

+ 1
- 1
react/features/base/react/components/native/Container.js 查看文件

@@ -1,4 +1,4 @@
1
-/* @flow */
1
+// @flow
2 2
 
3 3
 import React from 'react';
4 4
 import {

+ 1
- 1
react/features/conference/components/Conference.native.js 查看文件

@@ -114,7 +114,7 @@ class Conference extends Component {
114 114
      * after this component is mounted.
115 115
      *
116 116
      * @inheritdoc
117
-     * returns {void}
117
+     * @returns {void}
118 118
      */
119 119
     componentDidMount() {
120 120
         // Set handling any hardware button presses for back navigation up.

+ 6
- 3
react/features/filmstrip/components/Filmstrip.native.js 查看文件

@@ -1,11 +1,14 @@
1
-/* @flow */
1
+// @flow
2 2
 
3 3
 import PropTypes from 'prop-types';
4 4
 import React, { Component } from 'react';
5 5
 import { ScrollView } from 'react-native';
6 6
 import { connect } from 'react-redux';
7 7
 
8
-import { AspectRatioAware, isNarrowAspectRatio } from '../../base/aspect-ratio';
8
+import {
9
+    isNarrowAspectRatio,
10
+    makeAspectRatioAware
11
+} from '../../base/aspect-ratio';
9 12
 import { Container } from '../../base/react';
10 13
 
11 14
 import Thumbnail from './Thumbnail';
@@ -148,4 +151,4 @@ function _mapStateToProps(state) {
148 151
     };
149 152
 }
150 153
 
151
-export default connect(_mapStateToProps)(AspectRatioAware(Filmstrip));
154
+export default connect(_mapStateToProps)(makeAspectRatioAware(Filmstrip));

+ 5
- 2
react/features/toolbox/components/Toolbox.native.js 查看文件

@@ -4,7 +4,10 @@ import { View } from 'react-native';
4 4
 import { connect } from 'react-redux';
5 5
 
6 6
 import { sendAnalyticsEvent } from '../../analytics';
7
-import { AspectRatioAware, isNarrowAspectRatio } from '../../base/aspect-ratio';
7
+import {
8
+    isNarrowAspectRatio,
9
+    makeAspectRatioAware
10
+} from '../../base/aspect-ratio';
8 11
 import { toggleAudioOnly } from '../../base/conference';
9 12
 import {
10 13
     MEDIA_TYPE,
@@ -439,4 +442,4 @@ function _mapStateToProps(state) {
439 442
 }
440 443
 
441 444
 export default connect(_mapStateToProps, _mapDispatchToProps)(
442
-    AspectRatioAware(Toolbox));
445
+    makeAspectRatioAware(Toolbox));

正在加载...
取消
保存