Skip to content

Commit 1ad1693

Browse files
committed
[change] Remove PropTypes exports and internal use
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
1 parent 924e891 commit 1ad1693

File tree

133 files changed

+1051
-3032
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+1051
-3032
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
"window": false,
3535
// Flow global types,
3636
"$Enum": false,
37+
"$PropertyType": false,
3738
"$ReadOnly": false,
39+
"$ReadOnlyArray": false,
3840
"CSSStyleSheet": false,
3941
"HTMLInputElement": false,
4042
"ReactClass": false,
@@ -66,7 +68,6 @@
6668
"no-dupe-class-members": 2,
6769
"no-dupe-keys": 2,
6870
"no-duplicate-case": 2,
69-
"no-duplicate-imports": 2,
7071
"no-empty-character-class": 2,
7172
"no-empty-pattern": 2,
7273
"no-eval": 2,

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Who is using React Native in production web apps?
3030

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

33+
Components and APIs deprecated in React Native are not supported by React Native for Web.
34+
3335
## Quick start
3436

3537
The easiest way to get started is to edit this
@@ -141,11 +143,9 @@ React Native v0.60
141143
| AppState || |
142144
| BackHandler | (✓) | Mock. No equivalent web APIs. |
143145
| Clipboard || |
144-
| ColorPropType || |
145146
| DeviceInfo | (✓) | Limited information. |
146147
| Dimensions || |
147148
| Easing || |
148-
| EdgeInsetsPropType || |
149149
| Geolocation || |
150150
| I18nManager || Includes additional support for runtime switch to RTL. |
151151
| InteractionManager | (✓) | |
@@ -158,14 +158,11 @@ React Native v0.60
158158
| PanResponder || |
159159
| PixelRatio || |
160160
| Platform || |
161-
| PointPropType || |
162161
| Settings || No equivalent web APIs. |
163162
| Share || Only available over HTTPS. Read about the [Web Share API](https://wicg.github.io/web-share/). |
164163
| StyleSheet || |
165-
| TextPropTypes || |
166164
| UIManager || |
167165
| Vibration || |
168-
| ViewPropTypes || |
169166

170167
## Contributing
171168

packages/babel-plugin-react-native-web/src/__tests__/__snapshots__/index-test.js.snap

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
exports[`Rewrite react-native to react-native-web export from "react-native": export from "react-native" 1`] = `
44
"
55
export { View } from 'react-native';
6-
export { ColorPropType, StyleSheet, Text, unstable_createElement } from 'react-native';
6+
export { StyleSheet, Text, unstable_createElement } from 'react-native';
77
88
↓ ↓ ↓ ↓ ↓ ↓
99
1010
export { default as View } from 'react-native-web/dist/exports/View';
11-
export { default as ColorPropType } from 'react-native-web/dist/exports/ColorPropType';
1211
export { default as StyleSheet } from 'react-native-web/dist/exports/StyleSheet';
1312
export { default as Text } from 'react-native-web/dist/exports/Text';
1413
export { default as unstable_createElement } from 'react-native-web/dist/exports/createElement';
@@ -18,12 +17,11 @@ export { default as unstable_createElement } from 'react-native-web/dist/exports
1817
exports[`Rewrite react-native to react-native-web export from "react-native-web": export from "react-native-web" 1`] = `
1918
"
2019
export { View } from 'react-native-web';
21-
export { ColorPropType, StyleSheet, Text, unstable_createElement } from 'react-native-web';
20+
export { StyleSheet, Text, unstable_createElement } from 'react-native-web';
2221
2322
↓ ↓ ↓ ↓ ↓ ↓
2423
2524
export { default as View } from 'react-native-web/dist/exports/View';
26-
export { default as ColorPropType } from 'react-native-web/dist/exports/ColorPropType';
2725
export { default as StyleSheet } from 'react-native-web/dist/exports/StyleSheet';
2826
export { default as Text } from 'react-native-web/dist/exports/Text';
2927
export { default as unstable_createElement } from 'react-native-web/dist/exports/createElement';
@@ -34,7 +32,7 @@ exports[`Rewrite react-native to react-native-web import from "native-native": i
3432
"
3533
import ReactNative from 'react-native';
3634
import { View } from 'react-native';
37-
import { Invalid, View as MyView, ViewPropTypes } from 'react-native';
35+
import { Invalid, View as MyView } from 'react-native';
3836
import * as ReactNativeModules from 'react-native';
3937
4038
↓ ↓ ↓ ↓ ↓ ↓
@@ -43,7 +41,6 @@ import ReactNative from 'react-native-web/dist/index';
4341
import View from 'react-native-web/dist/exports/View';
4442
import { Invalid } from 'react-native-web/dist/index';
4543
import MyView from 'react-native-web/dist/exports/View';
46-
import ViewPropTypes from 'react-native-web/dist/exports/ViewPropTypes';
4744
import * as ReactNativeModules from 'react-native-web/dist/index';
4845
"
4946
`;
@@ -52,7 +49,7 @@ exports[`Rewrite react-native to react-native-web import from "native-native": i
5249
"
5350
import ReactNative from 'react-native';
5451
import { View } from 'react-native';
55-
import { Invalid, View as MyView, ViewPropTypes } from 'react-native';
52+
import { Invalid, View as MyView } from 'react-native';
5653
import * as ReactNativeModules from 'react-native';
5754
5855
↓ ↓ ↓ ↓ ↓ ↓
@@ -61,21 +58,19 @@ import ReactNative from 'react-native-web/dist/cjs/index';
6158
import View from 'react-native-web/dist/cjs/exports/View';
6259
import { Invalid } from 'react-native-web/dist/cjs/index';
6360
import MyView from 'react-native-web/dist/cjs/exports/View';
64-
import ViewPropTypes from 'react-native-web/dist/cjs/exports/ViewPropTypes';
6561
import * as ReactNativeModules from 'react-native-web/dist/cjs/index';
6662
"
6763
`;
6864

6965
exports[`Rewrite react-native to react-native-web import from "react-native-web": import from "react-native-web" 1`] = `
7066
"
7167
import { unstable_createElement } from 'react-native-web';
72-
import { ColorPropType, StyleSheet, View, TouchableOpacity, processColor } from 'react-native-web';
68+
import { StyleSheet, View, TouchableOpacity, processColor } from 'react-native-web';
7369
import * as ReactNativeModules from 'react-native-web';
7470
7571
↓ ↓ ↓ ↓ ↓ ↓
7672
7773
import unstable_createElement from 'react-native-web/dist/exports/createElement';
78-
import ColorPropType from 'react-native-web/dist/exports/ColorPropType';
7974
import StyleSheet from 'react-native-web/dist/exports/StyleSheet';
8075
import View from 'react-native-web/dist/exports/View';
8176
import TouchableOpacity from 'react-native-web/dist/exports/TouchableOpacity';
@@ -124,16 +119,14 @@ exports[`Rewrite react-native to react-native-web require "react-native-web": re
124119
"
125120
const ReactNative = require('react-native-web');
126121
const { unstable_createElement } = require('react-native-web');
127-
const { ColorPropType, StyleSheet, View, TouchableOpacity, processColor } = require('react-native-web');
122+
const { StyleSheet, View, TouchableOpacity, processColor } = require('react-native-web');
128123
129124
↓ ↓ ↓ ↓ ↓ ↓
130125
131126
const ReactNative = require('react-native-web/dist/index');
132127
133128
const unstable_createElement = require('react-native-web/dist/exports/createElement').default;
134129
135-
const ColorPropType = require('react-native-web/dist/exports/ColorPropType').default;
136-
137130
const StyleSheet = require('react-native-web/dist/exports/StyleSheet').default;
138131
139132
const View = require('react-native-web/dist/exports/View').default;

packages/babel-plugin-react-native-web/src/__tests__/index-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,36 @@ const tests = [
77
title: 'import from "native-native"',
88
code: `import ReactNative from 'react-native';
99
import { View } from 'react-native';
10-
import { Invalid, View as MyView, ViewPropTypes } from 'react-native';
10+
import { Invalid, View as MyView } from 'react-native';
1111
import * as ReactNativeModules from 'react-native';`,
1212
snapshot: true
1313
},
1414
{
1515
title: 'import from "native-native"',
1616
code: `import ReactNative from 'react-native';
1717
import { View } from 'react-native';
18-
import { Invalid, View as MyView, ViewPropTypes } from 'react-native';
18+
import { Invalid, View as MyView } from 'react-native';
1919
import * as ReactNativeModules from 'react-native';`,
2020
snapshot: true,
2121
pluginOptions: { commonjs: true }
2222
},
2323
{
2424
title: 'import from "react-native-web"',
2525
code: `import { unstable_createElement } from 'react-native-web';
26-
import { ColorPropType, StyleSheet, View, TouchableOpacity, processColor } from 'react-native-web';
26+
import { StyleSheet, View, TouchableOpacity, processColor } from 'react-native-web';
2727
import * as ReactNativeModules from 'react-native-web';`,
2828
snapshot: true
2929
},
3030
{
3131
title: 'export from "react-native"',
3232
code: `export { View } from 'react-native';
33-
export { ColorPropType, StyleSheet, Text, unstable_createElement } from 'react-native';`,
33+
export { StyleSheet, Text, unstable_createElement } from 'react-native';`,
3434
snapshot: true
3535
},
3636
{
3737
title: 'export from "react-native-web"',
3838
code: `export { View } from 'react-native-web';
39-
export { ColorPropType, StyleSheet, Text, unstable_createElement } from 'react-native-web';`,
39+
export { StyleSheet, Text, unstable_createElement } from 'react-native-web';`,
4040
snapshot: true
4141
},
4242
{
@@ -58,7 +58,7 @@ const { StyleSheet, TouchableOpacity } = require('react-native');`,
5858
title: 'require "react-native-web"',
5959
code: `const ReactNative = require('react-native-web');
6060
const { unstable_createElement } = require('react-native-web');
61-
const { ColorPropType, StyleSheet, View, TouchableOpacity, processColor } = require('react-native-web');`,
61+
const { StyleSheet, View, TouchableOpacity, processColor } = require('react-native-web');`,
6262
snapshot: true
6363
}
6464
];

packages/babel-plugin-react-native-web/src/moduleMap.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ module.exports = {
1010
Button: true,
1111
CheckBox: true,
1212
Clipboard: true,
13-
ColorPropType: true,
1413
DeviceEventEmitter: true,
1514
DeviceInfo: true,
1615
Dimensions: true,
1716
DrawerLayoutAndroid: true,
1817
Easing: true,
19-
EdgeInsetsPropType: true,
2018
FlatList: true,
2119
I18nManager: true,
2220
Image: true,
@@ -35,7 +33,6 @@ module.exports = {
3533
Picker: true,
3634
PixelRatio: true,
3735
Platform: true,
38-
PointPropType: true,
3936
ProgressBar: true,
4037
RefreshControl: true,
4138
SafeAreaView: true,
@@ -51,7 +48,6 @@ module.exports = {
5148
TabBarIOS: true,
5249
Text: true,
5350
TextInput: true,
54-
TextPropTypes: true,
5551
TimePickerAndroid: true,
5652
ToastAndroid: true,
5753
Touchable: true,
@@ -62,7 +58,6 @@ module.exports = {
6258
UIManager: true,
6359
Vibration: true,
6460
View: true,
65-
ViewPropTypes: true,
6661
VirtualizedList: true,
6762
YellowBox: true,
6863
createElement: true,

packages/benchmarks/src/app/App.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable react/prop-types */
2-
31
import Benchmark from './Benchmark';
42
import { Picker, StyleSheet, ScrollView, TouchableOpacity, View } from 'react-native';
53
import React, { Component } from 'react';

packages/benchmarks/src/app/Benchmark/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
/* global $Values */
9-
/* eslint-disable react/prop-types */
109

1110
import * as Timing from './timing';
1211
import React, { Component } from 'react';

packages/benchmarks/src/app/Button.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
import { ColorPropType, StyleSheet, TouchableHighlight, Text } from 'react-native';
1+
import { StyleSheet, TouchableHighlight, Text } from 'react-native';
22
import React, { Component } from 'react';
3-
import { bool, func, string } from 'prop-types';
43

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

8-
static propTypes = {
9-
accessibilityLabel: string,
10-
color: ColorPropType,
11-
disabled: bool,
12-
onPress: func.isRequired,
13-
style: TouchableHighlight.propTypes.style,
14-
testID: string,
15-
textStyle: Text.propTypes.style,
16-
title: string.isRequired
17-
};
18-
197
render() {
208
const {
219
accessibilityLabel,

packages/benchmarks/src/app/Layout.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
import { colors } from './theme';
2-
import { element } from 'prop-types';
32
import React, { Component } from 'react';
43
import { StyleSheet, View } from 'react-native';
54

65
export default class Layout extends Component {
7-
static propTypes = {
8-
actionPanel: element,
9-
listPanel: element,
10-
viewPanel: element
11-
};
12-
136
state = {
147
widescreen: false
158
};

packages/benchmarks/src/app/ReportCard.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable react/prop-types */
21
import Text from './Text';
32
import { StyleSheet, View } from 'react-native';
43
import React, { Fragment } from 'react';

0 commit comments

Comments
 (0)