[RN] Fix root component's prop types

This commit is contained in:
Saúl Ibarra Corretgé 2017-07-31 15:30:31 +02:00
parent da1c760abf
commit 0983ef48b5
1 changed files with 8 additions and 4 deletions

View File

@ -3,6 +3,7 @@ import React, { Component } from 'react';
import { AppRegistry, Linking } from 'react-native'; import { AppRegistry, Linking } from 'react-native';
import { App } from './features/app'; import { App } from './features/app';
import { equals } from './features/base/redux';
/** /**
* React Native doesn't support specifying props to the main/root component (in * React Native doesn't support specifying props to the main/root component (in
@ -21,7 +22,10 @@ class Root extends Component {
/** /**
* The URL, if any, with which the app was launched. * The URL, if any, with which the app was launched.
*/ */
url: React.PropTypes.string, url: React.PropTypes.oneOfType([
React.PropTypes.object,
React.PropTypes.string
]),
/** /**
* Whether the Welcome page is enabled. If {@code true}, the Welcome * Whether the Welcome page is enabled. If {@code true}, the Welcome
@ -44,14 +48,14 @@ class Root extends Component {
* The initial state of this Component. * The initial state of this Component.
* *
* @type {{ * @type {{
* url: string * url: object|string
* }} * }}
*/ */
this.state = { this.state = {
/** /**
* The URL, if any, with which the app was launched. * The URL, if any, with which the app was launched.
* *
* @type {string} * @type {object|string}
*/ */
url: this.props.url url: this.props.url
}; };
@ -86,7 +90,7 @@ class Root extends Component {
* @inheritdoc * @inheritdoc
*/ */
componentWillReceiveProps({ url }) { componentWillReceiveProps({ url }) {
if (this.props.url !== url) { if (!equals(this.props.url, url)) {
this.setState({ url: url || null }); this.setState({ url: url || null });
} }
} }