Преглед на файлове

[RN] Fix jsdocs, formatting. Add flow

j8
Lyubo Marinov преди 8 години
родител
ревизия
24eb37ae1e

+ 24
- 16
react/features/base/react/components/AbstractContainer.js Целия файл

@@ -1,13 +1,16 @@
1
+/* @flow */
2
+
1 3
 import React, { Component } from 'react';
2 4
 
3 5
 /**
4
- * Abstract (base) class for container of React Component children with a style.
6
+ * Abstract (base) class for container of React {@link Component} children with
7
+ * a style.
5 8
  *
6 9
  * @extends Component
7 10
  */
8 11
 export default class AbstractContainer extends Component {
9 12
     /**
10
-     * AbstractContainer component's property types.
13
+     * {@code AbstractContainer} component's property types.
11 14
      *
12 15
      * @static
13 16
      */
@@ -15,38 +18,43 @@ export default class AbstractContainer extends Component {
15 18
         children: React.PropTypes.node,
16 19
 
17 20
         /**
18
-         * The event handler/listener to be invoked when this AbstractContainer
19
-         * is clicked on Web or pressed on React Native. If onClick is defined
20
-         * and touchFeedback is undefined, touchFeedback is considered defined
21
-         * as true.
21
+         * The event handler/listener to be invoked when this
22
+         * {@code AbstractContainer} is clicked on Web or pressed on React
23
+         * Native. If {@code onClick} is defined and {@link touchFeedback} is
24
+         * undefined, {@code touchFeedback} is considered defined as
25
+         * {@code true}.
22 26
          */
23 27
         onClick: React.PropTypes.func,
24 28
 
25 29
         /**
26
-         * The style (as in stylesheet) to be applied to this AbstractContainer.
30
+         * The style (as in stylesheet) to be applied to this
31
+         * {@code AbstractContainer}.
27 32
          */
28 33
         style: React.PropTypes.object,
29 34
 
30 35
         /**
31
-         * True if this instance is to provide visual feedback when touched;
32
-         * otherwise, false. If touchFeedback is undefined and onClick is
33
-         * defined, touchFeedback is considered defined as true.
36
+         * If this instance is to provide visual feedback when touched, then
37
+         * {@code true}; otherwise, {@code false}. If {@code touchFeedback} is
38
+         * undefined and {@link onClick} is defined, {@code touchFeedback} is
39
+         * considered defined as {@code true}.
34 40
          */
35 41
         touchFeedback: React.PropTypes.bool,
36 42
 
37 43
         /**
38
-         * True if this AbstractContainer is to be visible or false if this
39
-         * instance is to be hidden or not rendered at all.
44
+         * If this {@code AbstractContainer} is to be visible, then {@code true}
45
+         * or {@code false} if this instance is to be hidden or not rendered at
46
+         * all.
40 47
          */
41 48
         visible: React.PropTypes.bool
42 49
     };
43 50
 
44 51
     /**
45
-     * Renders this AbstractContainer as a React Component of a specific type.
52
+     * Renders this {@code AbstractContainer} as a React {@code Component} of a
53
+     * specific type.
46 54
      *
47
-     * @param {string|ReactClass} type - The type of the React Component which
48
-     * is to be rendered.
49
-     * @param {Object|undefined} props - The read-only React Component
55
+     * @param {string|ReactClass} type - The type of the React {@code Component}
56
+     * which is to be rendered.
57
+     * @param {Object|undefined} props - The read-only React {@code Component}
50 58
      * properties, if any, to render. If undefined, the props of this instance
51 59
      * will be rendered.
52 60
      * @protected

+ 8
- 9
react/features/base/react/components/native/Container.js Целия файл

@@ -1,3 +1,5 @@
1
+/* @flow */
2
+
1 3
 import React from 'react';
2 4
 import {
3 5
     Dimensions,
@@ -31,6 +33,9 @@ export default class Container extends AbstractContainer {
31 33
         // eslint-disable-next-line prefer-const
32 34
         let { onClick, style, touchFeedback, visible, ...props } = this.props;
33 35
 
36
+        // onClick & touchFeedback
37
+        (typeof touchFeedback === 'undefined') && (touchFeedback = onClick);
38
+
34 39
         // visible
35 40
 
36 41
         // The following property is responsible to hide/show this Container by
@@ -50,9 +55,6 @@ export default class Container extends AbstractContainer {
50 55
             };
51 56
         }
52 57
 
53
-        // onClick & touchFeedback
54
-        (typeof touchFeedback === 'undefined') && (touchFeedback = onClick);
55
-
56 58
         const renderParent = touchFeedback || onClick;
57 59
 
58 60
         if (!renderParent && visibilityStyle) {
@@ -63,20 +65,17 @@ export default class Container extends AbstractContainer {
63 65
         }
64 66
 
65 67
         // eslint-disable-next-line object-property-newline
66
-        let component = this._render(View, { ...props, style });
68
+        let component = super._render(View, { ...props, style });
67 69
 
68 70
         if (renderParent) {
69 71
             const parentType
70
-                = touchFeedback
71
-                    ? TouchableHighlight
72
-                    : TouchableWithoutFeedback;
72
+                = touchFeedback ? TouchableHighlight : TouchableWithoutFeedback;
73 73
             const parentProps = {};
74 74
 
75 75
             onClick && (parentProps.onPress = onClick);
76 76
             visibilityStyle && (parentProps.style = visibilityStyle);
77 77
 
78
-            component
79
-                = React.createElement(parentType, parentProps, component);
78
+            component = React.createElement(parentType, parentProps, component);
80 79
         }
81 80
 
82 81
         return component;

+ 6
- 5
react/features/base/react/components/web/Container.js Целия файл

@@ -1,3 +1,5 @@
1
+/* @flow */
2
+
1 3
 import AbstractContainer from '../AbstractContainer';
2 4
 
3 5
 /**
@@ -22,10 +24,9 @@ export default class Container extends AbstractContainer {
22 24
     render() {
23 25
         const { visible } = this.props;
24 26
 
25
-        if (typeof visible !== 'undefined' && !visible) {
26
-            return null;
27
-        }
28
-
29
-        return this._render('div');
27
+        return (
28
+            typeof visible === 'undefined' || visible
29
+                ? super._render('div')
30
+                : null);
30 31
     }
31 32
 }

Loading…
Отказ
Запис