瀏覽代碼

[RN] Fix jsdocs, formatting. Add flow

j8
Lyubo Marinov 8 年之前
父節點
當前提交
24eb37ae1e

+ 24
- 16
react/features/base/react/components/AbstractContainer.js 查看文件

1
+/* @flow */
2
+
1
 import React, { Component } from 'react';
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
  * @extends Component
9
  * @extends Component
7
  */
10
  */
8
 export default class AbstractContainer extends Component {
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
      * @static
15
      * @static
13
      */
16
      */
15
         children: React.PropTypes.node,
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
         onClick: React.PropTypes.func,
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
         style: React.PropTypes.object,
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
         touchFeedback: React.PropTypes.bool,
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
         visible: React.PropTypes.bool
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
      * properties, if any, to render. If undefined, the props of this instance
58
      * properties, if any, to render. If undefined, the props of this instance
51
      * will be rendered.
59
      * will be rendered.
52
      * @protected
60
      * @protected

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

1
+/* @flow */
2
+
1
 import React from 'react';
3
 import React from 'react';
2
 import {
4
 import {
3
     Dimensions,
5
     Dimensions,
31
         // eslint-disable-next-line prefer-const
33
         // eslint-disable-next-line prefer-const
32
         let { onClick, style, touchFeedback, visible, ...props } = this.props;
34
         let { onClick, style, touchFeedback, visible, ...props } = this.props;
33
 
35
 
36
+        // onClick & touchFeedback
37
+        (typeof touchFeedback === 'undefined') && (touchFeedback = onClick);
38
+
34
         // visible
39
         // visible
35
 
40
 
36
         // The following property is responsible to hide/show this Container by
41
         // The following property is responsible to hide/show this Container by
50
             };
55
             };
51
         }
56
         }
52
 
57
 
53
-        // onClick & touchFeedback
54
-        (typeof touchFeedback === 'undefined') && (touchFeedback = onClick);
55
-
56
         const renderParent = touchFeedback || onClick;
58
         const renderParent = touchFeedback || onClick;
57
 
59
 
58
         if (!renderParent && visibilityStyle) {
60
         if (!renderParent && visibilityStyle) {
63
         }
65
         }
64
 
66
 
65
         // eslint-disable-next-line object-property-newline
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
         if (renderParent) {
70
         if (renderParent) {
69
             const parentType
71
             const parentType
70
-                = touchFeedback
71
-                    ? TouchableHighlight
72
-                    : TouchableWithoutFeedback;
72
+                = touchFeedback ? TouchableHighlight : TouchableWithoutFeedback;
73
             const parentProps = {};
73
             const parentProps = {};
74
 
74
 
75
             onClick && (parentProps.onPress = onClick);
75
             onClick && (parentProps.onPress = onClick);
76
             visibilityStyle && (parentProps.style = visibilityStyle);
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
         return component;
81
         return component;

+ 6
- 5
react/features/base/react/components/web/Container.js 查看文件

1
+/* @flow */
2
+
1
 import AbstractContainer from '../AbstractContainer';
3
 import AbstractContainer from '../AbstractContainer';
2
 
4
 
3
 /**
5
 /**
22
     render() {
24
     render() {
23
         const { visible } = this.props;
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…
取消
儲存