瀏覽代碼

React & React Native Fragment-like

master
Lyubo Marinov 8 年之前
父節點
當前提交
b39b6640b4

+ 1
- 28
react/features/app/components/AbstractApp.js 查看文件

@@ -1,5 +1,4 @@
1 1
 /* global APP */
2
-/* eslint-disable react/no-multi-comp */
3 2
 
4 3
 import PropTypes from 'prop-types';
5 4
 import React, { Component } from 'react';
@@ -13,7 +12,7 @@ import {
13 12
     localParticipantJoined,
14 13
     localParticipantLeft
15 14
 } from '../../base/participants';
16
-import { RouteRegistry } from '../../base/react';
15
+import { Fragment, RouteRegistry } from '../../base/react';
17 16
 import { MiddlewareRegistry, ReducerRegistry } from '../../base/redux';
18 17
 import { toURLString } from '../../base/util';
19 18
 import { OverlayContainer } from '../../overlay';
@@ -27,32 +26,6 @@ import { appNavigate, appWillMount, appWillUnmount } from '../actions';
27 26
  */
28 27
 const DEFAULT_URL = 'https://meet.jit.si';
29 28
 
30
-/**
31
- * react-redux's {@code Provider} component only accepts a single child, so use
32
- * a simple wrapper component in order to pass more than 1 child components.
33
- * TODO: remove this once React Native supports Fragment (0.52 probably).
34
- */
35
-class Fragment extends Component {
36
-    /**
37
-     * {@code Fragment} component's property types.
38
-     *
39
-     * @static
40
-     */
41
-    static propTypes = {
42
-        children: PropTypes.node
43
-    };
44
-
45
-    /**
46
-     * Implements React's {@link Component#render()}.
47
-     *
48
-     * @inheritdoc
49
-     * @returns {ReactElement}
50
-     */
51
-    render() {
52
-        return this.props.children;
53
-    }
54
-}
55
-
56 29
 /**
57 30
  * Base (abstract) class for main App component.
58 31
  *

+ 30
- 0
react/features/base/react/components/Fragment.js 查看文件

@@ -0,0 +1,30 @@
1
+// @flow
2
+
3
+import { Component } from 'react';
4
+
5
+/**
6
+ * {@code Fragment} component's property types.
7
+ *
8
+ * @static
9
+ */
10
+type Props = {
11
+    children: React$Node
12
+};
13
+
14
+/**
15
+ * react-redux's {@code Provider} component only accepts a single child, so use
16
+ * a simple wrapper component in order to pass more than 1 child components.
17
+ *
18
+ * TODO Remove once React Native supports Fragment (0.52 probably).
19
+ */
20
+export default class Fragment extends Component<Props> {
21
+    /**
22
+     * Implements React's {@link Component#render()}.
23
+     *
24
+     * @inheritdoc
25
+     * @returns {React$Node}
26
+     */
27
+    render() {
28
+        return this.props.children;
29
+    }
30
+}

+ 1
- 0
react/features/base/react/components/index.js 查看文件

@@ -1 +1,2 @@
1 1
 export * from './_';
2
+export { default as Fragment } from './Fragment';

Loading…
取消
儲存