React & React Native Fragment-like

This commit is contained in:
Lyubo Marinov 2017-12-07 20:31:28 -06:00
parent 870e6bbddc
commit b39b6640b4
3 changed files with 32 additions and 28 deletions

View File

@ -1,5 +1,4 @@
/* global APP */ /* global APP */
/* eslint-disable react/no-multi-comp */
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
@ -13,7 +12,7 @@ import {
localParticipantJoined, localParticipantJoined,
localParticipantLeft localParticipantLeft
} from '../../base/participants'; } from '../../base/participants';
import { RouteRegistry } from '../../base/react'; import { Fragment, RouteRegistry } from '../../base/react';
import { MiddlewareRegistry, ReducerRegistry } from '../../base/redux'; import { MiddlewareRegistry, ReducerRegistry } from '../../base/redux';
import { toURLString } from '../../base/util'; import { toURLString } from '../../base/util';
import { OverlayContainer } from '../../overlay'; import { OverlayContainer } from '../../overlay';
@ -27,32 +26,6 @@ import { appNavigate, appWillMount, appWillUnmount } from '../actions';
*/ */
const DEFAULT_URL = 'https://meet.jit.si'; const DEFAULT_URL = 'https://meet.jit.si';
/**
* react-redux's {@code Provider} component only accepts a single child, so use
* a simple wrapper component in order to pass more than 1 child components.
* TODO: remove this once React Native supports Fragment (0.52 probably).
*/
class Fragment extends Component {
/**
* {@code Fragment} component's property types.
*
* @static
*/
static propTypes = {
children: PropTypes.node
};
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
return this.props.children;
}
}
/** /**
* Base (abstract) class for main App component. * Base (abstract) class for main App component.
* *

View File

@ -0,0 +1,30 @@
// @flow
import { Component } from 'react';
/**
* {@code Fragment} component's property types.
*
* @static
*/
type Props = {
children: React$Node
};
/**
* react-redux's {@code Provider} component only accepts a single child, so use
* a simple wrapper component in order to pass more than 1 child components.
*
* TODO Remove once React Native supports Fragment (0.52 probably).
*/
export default class Fragment extends Component<Props> {
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {React$Node}
*/
render() {
return this.props.children;
}
}

View File

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