mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
Prettier the rest of ReactNative
Reviewed By: yungsters Differential Revision: D7974340 fbshipit-source-id: 5fe457a8a9be4bd360fc3af9acb5c1136b2be0d7
This commit is contained in:
committed by
Facebook Github Bot
parent
aba4ec0c09
commit
36fcbaa56d
@@ -4,19 +4,20 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {
|
||||
Dimensions,
|
||||
Text,
|
||||
View
|
||||
} = ReactNative;
|
||||
const {Dimensions, Text, View} = ReactNative;
|
||||
|
||||
class DimensionsSubscription extends React.Component<{dim: string}, {dims: Object}> {
|
||||
class DimensionsSubscription extends React.Component<
|
||||
{dim: string},
|
||||
{dims: Object},
|
||||
> {
|
||||
state = {
|
||||
dims: Dimensions.get(this.props.dim),
|
||||
};
|
||||
@@ -29,7 +30,7 @@ class DimensionsSubscription extends React.Component<{dim: string}, {dims: Objec
|
||||
Dimensions.removeEventListener('change', this._handleDimensionsChange);
|
||||
}
|
||||
|
||||
_handleDimensionsChange = (dimensions) => {
|
||||
_handleDimensionsChange = dimensions => {
|
||||
this.setState({
|
||||
dims: dimensions[this.props.dim],
|
||||
});
|
||||
@@ -49,10 +50,14 @@ exports.description = 'Dimensions of the viewport';
|
||||
exports.examples = [
|
||||
{
|
||||
title: 'window',
|
||||
render(): React.Element<any> { return <DimensionsSubscription dim="window" />; }
|
||||
render(): React.Element<any> {
|
||||
return <DimensionsSubscription dim="window" />;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'screen',
|
||||
render(): React.Element<any> { return <DimensionsSubscription dim="screen" />; }
|
||||
render(): React.Element<any> {
|
||||
return <DimensionsSubscription dim="screen" />;
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user