Skip to content

Commit

Permalink
[change] Remove PropTypes exports and internal use
Browse files Browse the repository at this point in the history
Removes the following deprecated exports: `ColorPropType`,
`EdgeInsetsPropType`, `PointPropType`, `TextPropTypes`, and `ViewPropTypes`.

Remove all use of `prop-types` in the implementations of components. Flow types
are used instead, so there will no longer be runtime warnings related to props.

NOTE: Removes support for `className` prop.

Fix #1383
Close #1477
Close #1474
Close #1489
  • Loading branch information
necolas committed Dec 18, 2019
1 parent 924e891 commit 1ad1693
Show file tree
Hide file tree
Showing 133 changed files with 1,051 additions and 3,032 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
"window": false,
// Flow global types,
"$Enum": false,
"$PropertyType": false,
"$ReadOnly": false,
"$ReadOnlyArray": false,
"CSSStyleSheet": false,
"HTMLInputElement": false,
"ReactClass": false,
Expand Down Expand Up @@ -66,7 +68,6 @@
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-duplicate-imports": 2,
"no-empty-character-class": 2,
"no-empty-pattern": 2,
"no-eval": 2,
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Who is using React Native in production web apps?

Browser support: Chrome, Firefox, Edge, Safari 7+, IE 10+.

Components and APIs deprecated in React Native are not supported by React Native for Web.

## Quick start

The easiest way to get started is to edit this
Expand Down Expand Up @@ -141,11 +143,9 @@ React Native v0.60
| AppState || |
| BackHandler | (✓) | Mock. No equivalent web APIs. |
| Clipboard || |
| ColorPropType || |
| DeviceInfo | (✓) | Limited information. |
| Dimensions || |
| Easing || |
| EdgeInsetsPropType || |
| Geolocation || |
| I18nManager || Includes additional support for runtime switch to RTL. |
| InteractionManager | (✓) | |
Expand All @@ -158,14 +158,11 @@ React Native v0.60
| PanResponder || |
| PixelRatio || |
| Platform || |
| PointPropType || |
| Settings || No equivalent web APIs. |
| Share || Only available over HTTPS. Read about the [Web Share API](https://wicg.github.io/web-share/). |
| StyleSheet || |
| TextPropTypes || |
| UIManager || |
| Vibration || |
| ViewPropTypes || |

## Contributing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
exports[`Rewrite react-native to react-native-web export from "react-native": export from "react-native" 1`] = `
"
export { View } from 'react-native';
export { ColorPropType, StyleSheet, Text, unstable_createElement } from 'react-native';
export { StyleSheet, Text, unstable_createElement } from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
export { default as View } from 'react-native-web/dist/exports/View';
export { default as ColorPropType } from 'react-native-web/dist/exports/ColorPropType';
export { default as StyleSheet } from 'react-native-web/dist/exports/StyleSheet';
export { default as Text } from 'react-native-web/dist/exports/Text';
export { default as unstable_createElement } from 'react-native-web/dist/exports/createElement';
Expand All @@ -18,12 +17,11 @@ export { default as unstable_createElement } from 'react-native-web/dist/exports
exports[`Rewrite react-native to react-native-web export from "react-native-web": export from "react-native-web" 1`] = `
"
export { View } from 'react-native-web';
export { ColorPropType, StyleSheet, Text, unstable_createElement } from 'react-native-web';
export { StyleSheet, Text, unstable_createElement } from 'react-native-web';
↓ ↓ ↓ ↓ ↓ ↓
export { default as View } from 'react-native-web/dist/exports/View';
export { default as ColorPropType } from 'react-native-web/dist/exports/ColorPropType';
export { default as StyleSheet } from 'react-native-web/dist/exports/StyleSheet';
export { default as Text } from 'react-native-web/dist/exports/Text';
export { default as unstable_createElement } from 'react-native-web/dist/exports/createElement';
Expand All @@ -34,7 +32,7 @@ exports[`Rewrite react-native to react-native-web import from "native-native": i
"
import ReactNative from 'react-native';
import { View } from 'react-native';
import { Invalid, View as MyView, ViewPropTypes } from 'react-native';
import { Invalid, View as MyView } from 'react-native';
import * as ReactNativeModules from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
Expand All @@ -43,7 +41,6 @@ import ReactNative from 'react-native-web/dist/index';
import View from 'react-native-web/dist/exports/View';
import { Invalid } from 'react-native-web/dist/index';
import MyView from 'react-native-web/dist/exports/View';
import ViewPropTypes from 'react-native-web/dist/exports/ViewPropTypes';
import * as ReactNativeModules from 'react-native-web/dist/index';
"
`;
Expand All @@ -52,7 +49,7 @@ exports[`Rewrite react-native to react-native-web import from "native-native": i
"
import ReactNative from 'react-native';
import { View } from 'react-native';
import { Invalid, View as MyView, ViewPropTypes } from 'react-native';
import { Invalid, View as MyView } from 'react-native';
import * as ReactNativeModules from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
Expand All @@ -61,21 +58,19 @@ import ReactNative from 'react-native-web/dist/cjs/index';
import View from 'react-native-web/dist/cjs/exports/View';
import { Invalid } from 'react-native-web/dist/cjs/index';
import MyView from 'react-native-web/dist/cjs/exports/View';
import ViewPropTypes from 'react-native-web/dist/cjs/exports/ViewPropTypes';
import * as ReactNativeModules from 'react-native-web/dist/cjs/index';
"
`;

exports[`Rewrite react-native to react-native-web import from "react-native-web": import from "react-native-web" 1`] = `
"
import { unstable_createElement } from 'react-native-web';
import { ColorPropType, StyleSheet, View, TouchableOpacity, processColor } from 'react-native-web';
import { StyleSheet, View, TouchableOpacity, processColor } from 'react-native-web';
import * as ReactNativeModules from 'react-native-web';
↓ ↓ ↓ ↓ ↓ ↓
import unstable_createElement from 'react-native-web/dist/exports/createElement';
import ColorPropType from 'react-native-web/dist/exports/ColorPropType';
import StyleSheet from 'react-native-web/dist/exports/StyleSheet';
import View from 'react-native-web/dist/exports/View';
import TouchableOpacity from 'react-native-web/dist/exports/TouchableOpacity';
Expand Down Expand Up @@ -124,16 +119,14 @@ exports[`Rewrite react-native to react-native-web require "react-native-web": re
"
const ReactNative = require('react-native-web');
const { unstable_createElement } = require('react-native-web');
const { ColorPropType, StyleSheet, View, TouchableOpacity, processColor } = require('react-native-web');
const { StyleSheet, View, TouchableOpacity, processColor } = require('react-native-web');
↓ ↓ ↓ ↓ ↓ ↓
const ReactNative = require('react-native-web/dist/index');
const unstable_createElement = require('react-native-web/dist/exports/createElement').default;
const ColorPropType = require('react-native-web/dist/exports/ColorPropType').default;
const StyleSheet = require('react-native-web/dist/exports/StyleSheet').default;
const View = require('react-native-web/dist/exports/View').default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@ const tests = [
title: 'import from "native-native"',
code: `import ReactNative from 'react-native';
import { View } from 'react-native';
import { Invalid, View as MyView, ViewPropTypes } from 'react-native';
import { Invalid, View as MyView } from 'react-native';
import * as ReactNativeModules from 'react-native';`,
snapshot: true
},
{
title: 'import from "native-native"',
code: `import ReactNative from 'react-native';
import { View } from 'react-native';
import { Invalid, View as MyView, ViewPropTypes } from 'react-native';
import { Invalid, View as MyView } from 'react-native';
import * as ReactNativeModules from 'react-native';`,
snapshot: true,
pluginOptions: { commonjs: true }
},
{
title: 'import from "react-native-web"',
code: `import { unstable_createElement } from 'react-native-web';
import { ColorPropType, StyleSheet, View, TouchableOpacity, processColor } from 'react-native-web';
import { StyleSheet, View, TouchableOpacity, processColor } from 'react-native-web';
import * as ReactNativeModules from 'react-native-web';`,
snapshot: true
},
{
title: 'export from "react-native"',
code: `export { View } from 'react-native';
export { ColorPropType, StyleSheet, Text, unstable_createElement } from 'react-native';`,
export { StyleSheet, Text, unstable_createElement } from 'react-native';`,
snapshot: true
},
{
title: 'export from "react-native-web"',
code: `export { View } from 'react-native-web';
export { ColorPropType, StyleSheet, Text, unstable_createElement } from 'react-native-web';`,
export { StyleSheet, Text, unstable_createElement } from 'react-native-web';`,
snapshot: true
},
{
Expand All @@ -58,7 +58,7 @@ const { StyleSheet, TouchableOpacity } = require('react-native');`,
title: 'require "react-native-web"',
code: `const ReactNative = require('react-native-web');
const { unstable_createElement } = require('react-native-web');
const { ColorPropType, StyleSheet, View, TouchableOpacity, processColor } = require('react-native-web');`,
const { StyleSheet, View, TouchableOpacity, processColor } = require('react-native-web');`,
snapshot: true
}
];
Expand Down
5 changes: 0 additions & 5 deletions packages/babel-plugin-react-native-web/src/moduleMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ module.exports = {
Button: true,
CheckBox: true,
Clipboard: true,
ColorPropType: true,
DeviceEventEmitter: true,
DeviceInfo: true,
Dimensions: true,
DrawerLayoutAndroid: true,
Easing: true,
EdgeInsetsPropType: true,
FlatList: true,
I18nManager: true,
Image: true,
Expand All @@ -35,7 +33,6 @@ module.exports = {
Picker: true,
PixelRatio: true,
Platform: true,
PointPropType: true,
ProgressBar: true,
RefreshControl: true,
SafeAreaView: true,
Expand All @@ -51,7 +48,6 @@ module.exports = {
TabBarIOS: true,
Text: true,
TextInput: true,
TextPropTypes: true,
TimePickerAndroid: true,
ToastAndroid: true,
Touchable: true,
Expand All @@ -62,7 +58,6 @@ module.exports = {
UIManager: true,
Vibration: true,
View: true,
ViewPropTypes: true,
VirtualizedList: true,
YellowBox: true,
createElement: true,
Expand Down
2 changes: 0 additions & 2 deletions packages/benchmarks/src/app/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable react/prop-types */

import Benchmark from './Benchmark';
import { Picker, StyleSheet, ScrollView, TouchableOpacity, View } from 'react-native';
import React, { Component } from 'react';
Expand Down
1 change: 0 additions & 1 deletion packages/benchmarks/src/app/Benchmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

/* global $Values */
/* eslint-disable react/prop-types */

import * as Timing from './timing';
import React, { Component } from 'react';
Expand Down
14 changes: 1 addition & 13 deletions packages/benchmarks/src/app/Button.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
import { ColorPropType, StyleSheet, TouchableHighlight, Text } from 'react-native';
import { StyleSheet, TouchableHighlight, Text } from 'react-native';
import React, { Component } from 'react';
import { bool, func, string } from 'prop-types';

export default class Button extends Component<*> {
static displayName = '@app/Button';

static propTypes = {
accessibilityLabel: string,
color: ColorPropType,
disabled: bool,
onPress: func.isRequired,
style: TouchableHighlight.propTypes.style,
testID: string,
textStyle: Text.propTypes.style,
title: string.isRequired
};

render() {
const {
accessibilityLabel,
Expand Down
7 changes: 0 additions & 7 deletions packages/benchmarks/src/app/Layout.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { colors } from './theme';
import { element } from 'prop-types';
import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';

export default class Layout extends Component {
static propTypes = {
actionPanel: element,
listPanel: element,
viewPanel: element
};

state = {
widescreen: false
};
Expand Down
1 change: 0 additions & 1 deletion packages/benchmarks/src/app/ReportCard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/prop-types */
import Text from './Text';
import { StyleSheet, View } from 'react-native';
import React, { Fragment } from 'react';
Expand Down
4 changes: 1 addition & 3 deletions packages/benchmarks/src/app/Text.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-disable react/prop-types */

import { bool } from 'prop-types';
import React from 'react';
import { StyleSheet, Text } from 'react-native';
import { bool } from 'prop-types';
import { colors } from './theme';

class AppText extends React.Component {
Expand Down
10 changes: 0 additions & 10 deletions packages/benchmarks/src/cases/SierpinskiTriangle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BenchmarkType } from '../app/Benchmark';
import { number, object } from 'prop-types';
import React from 'react';
import { interpolatePurples, interpolateBuPu, interpolateRdPu } from 'd3-scale-chromatic';

Expand All @@ -10,15 +9,6 @@ class SierpinskiTriangle extends React.Component {

static benchmarkType = BenchmarkType.UPDATE;

static propTypes = {
components: object,
depth: number,
renderCount: number,
s: number,
x: number,
y: number
};

static defaultProps = {
depth: 0,
renderCount: 0
Expand Down
9 changes: 0 additions & 9 deletions packages/benchmarks/src/cases/TextTree.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import { BenchmarkType } from '../app/Benchmark';
import { number, object } from 'prop-types';
import React, { Component } from 'react';

class TextTree extends Component {
static displayName = 'TextTree';

static benchmarkType = BenchmarkType.MOUNT;

static propTypes = {
breadth: number.isRequired,
components: object,
depth: number.isRequired,
id: number.isRequired,
wrap: number.isRequired
};

render() {
const { breadth, components, depth, id, wrap } = this.props;
const { TextBox } = components;
Expand Down
9 changes: 0 additions & 9 deletions packages/benchmarks/src/cases/Tree.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import { BenchmarkType } from '../app/Benchmark';
import { number, object } from 'prop-types';
import React, { Component } from 'react';

class Tree extends Component {
static displayName = 'Tree';

static benchmarkType = BenchmarkType.MOUNT;

static propTypes = {
breadth: number.isRequired,
components: object,
depth: number.isRequired,
id: number.isRequired,
wrap: number.isRequired
};

render() {
const { breadth, components, depth, id, wrap } = this.props;
const { Box } = components;
Expand Down
1 change: 0 additions & 1 deletion packages/benchmarks/src/implementations/aphrodite/Box.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/prop-types */
import React from 'react';
import View from './View';
import { StyleSheet } from 'aphrodite';
Expand Down
1 change: 0 additions & 1 deletion packages/benchmarks/src/implementations/aphrodite/View.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/prop-types */
import React from 'react';
import { css, StyleSheet } from 'aphrodite';

Expand Down
1 change: 0 additions & 1 deletion packages/benchmarks/src/implementations/css-modules/Box.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/prop-types */
import classnames from 'classnames';
import React from 'react';
import View from './View';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/prop-types */
import classnames from 'classnames';
import React from 'react';
import styles from './view-styles.css';
Expand Down
1 change: 0 additions & 1 deletion packages/benchmarks/src/implementations/emotion/Box.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/prop-types */
import React from 'react';
import View from './View';

Expand Down
1 change: 0 additions & 1 deletion packages/benchmarks/src/implementations/emotion/Dot.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/prop-types */
import React from 'react';
import { css } from 'emotion';

Expand Down
Loading

0 comments on commit 1ad1693

Please sign in to comment.