Skip to content

Commit 859a2c4

Browse files
author
Ali Najafizadeh
committed
Merge pull request #52 from ticketea/proxy-proptypes
Proxy WebView proptypes to simplify
2 parents 49dd503 + 62cd927 commit 859a2c4

File tree

2 files changed

+5
-132
lines changed

2 files changed

+5
-132
lines changed

webview-bridge/index.android.js

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var {
2525
StyleSheet,
2626
Text,
2727
View,
28+
WebView,
2829
requireNativeComponent,
2930
PropTypes,
3031
DeviceEventEmitter,
@@ -47,48 +48,7 @@ var WebViewBridgeState = keyMirror({
4748
var WebViewBridge = React.createClass({
4849

4950
propTypes: {
50-
...View.propTypes,
51-
renderError: PropTypes.func,
52-
renderLoading: PropTypes.func,
53-
onLoad: PropTypes.func,
54-
onLoadEnd: PropTypes.func,
55-
onLoadStart: PropTypes.func,
56-
onError: PropTypes.func,
57-
url: PropTypes.string,
58-
html: PropTypes.string,
59-
automaticallyAdjustContentInsets: PropTypes.bool,
60-
contentInset: EdgeInsetsPropType,
61-
onNavigationStateChange: PropTypes.func,
62-
startInLoadingState: PropTypes.bool, // force WebView to show loadingView on first load
63-
style: View.propTypes.style,
64-
65-
/**
66-
* Used on Android only, JS is enabled by default for WebView on iOS
67-
* @platform android
68-
*/
69-
javaScriptEnabled: PropTypes.bool,
70-
71-
/**
72-
* Used on Android only, controls whether DOM Storage is enabled or not
73-
* @platform android
74-
*/
75-
domStorageEnabled: PropTypes.bool,
76-
77-
/**
78-
* Sets the JS to be injected when the webpage loads.
79-
*/
80-
injectedJavaScript: PropTypes.string,
81-
82-
/**
83-
* Sets the user-agent for this WebView. The user-agent can also be set in native using
84-
* WebViewConfig. This prop will overwrite that config.
85-
*/
86-
userAgent: PropTypes.string,
87-
88-
/**
89-
* Used to locate this view in end-to-end tests.
90-
*/
91-
testID: PropTypes.string,
51+
...WebView.propTypes,
9252

9353
/**
9454
* Will be called once the message is being sent from webview
@@ -151,19 +111,11 @@ var WebViewBridge = React.createClass({
151111
<RCTWebViewBridge
152112
ref={RCT_WEBVIEWBRIDGE_REF}
153113
key="webViewKey"
114+
{...this.props}
154115
style={webViewStyles}
155-
url={this.props.url}
156-
html={this.props.html}
157-
injectedJavaScript={this.props.injectedJavaScript}
158-
userAgent={this.props.userAgent}
159-
javaScriptEnabled={javaScriptEnabled}
160-
domStorageEnabled={domStorageEnabled}
161-
contentInset={this.props.contentInset}
162-
automaticallyAdjustContentInsets={this.props.automaticallyAdjustContentInsets}
163116
onLoadingStart={this.onLoadingStart}
164117
onLoadingFinish={this.onLoadingFinish}
165118
onLoadingError={this.onLoadingError}
166-
testID={this.props.testID}
167119
/>;
168120

169121
return (

webview-bridge/index.ios.js

Lines changed: 2 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var {
2424
StyleSheet,
2525
Text,
2626
View,
27+
WebView,
2728
requireNativeComponent,
2829
PropTypes,
2930
UIManager,
@@ -94,87 +95,7 @@ var WebViewBridge = React.createClass({
9495
},
9596

9697
propTypes: {
97-
...View.propTypes,
98-
url: PropTypes.string,
99-
html: PropTypes.string,
100-
/**
101-
* Function that returns a view to show if there's an error.
102-
*/
103-
renderError: PropTypes.func, // view to show if there's an error
104-
/**
105-
* Function that returns a loading indicator.
106-
*/
107-
renderLoading: PropTypes.func,
108-
/**
109-
* Invoked when load finish
110-
*/
111-
onLoad: PropTypes.func,
112-
/**
113-
* Invoked when load either succeeds or fails
114-
*/
115-
onLoadEnd: PropTypes.func,
116-
/**
117-
* Invoked on load start
118-
*/
119-
onLoadStart: PropTypes.func,
120-
/**
121-
* Invoked when load fails
122-
*/
123-
onError: PropTypes.func,
124-
/**
125-
* @platform ios
126-
*/
127-
bounces: PropTypes.bool,
128-
/**
129-
* @platform ios
130-
*/
131-
scrollEnabled: PropTypes.bool,
132-
automaticallyAdjustContentInsets: PropTypes.bool,
133-
contentInset: EdgeInsetsPropType,
134-
onNavigationStateChange: PropTypes.func,
135-
startInLoadingState: PropTypes.bool, // force WebView to show loadingView on first load
136-
style: View.propTypes.style,
137-
138-
/**
139-
* Used on Android only, JS is enabled by default for WebView on iOS
140-
* @platform android
141-
*/
142-
javaScriptEnabled: PropTypes.bool,
143-
144-
/**
145-
* Used on Android only, controls whether DOM Storage is enabled or not
146-
* @platform android
147-
*/
148-
domStorageEnabled: PropTypes.bool,
149-
150-
/**
151-
* Sets the JS to be injected when the webpage loads.
152-
*/
153-
injectedJavaScript: PropTypes.string,
154-
155-
/**
156-
* Sets whether the webpage scales to fit the view and the user can change the scale.
157-
* @platform ios
158-
*/
159-
scalesPageToFit: PropTypes.bool,
160-
161-
/**
162-
* Allows custom handling of any webview requests by a JS handler. Return true
163-
* or false from this method to continue loading the request.
164-
* @platform ios
165-
*/
166-
onShouldStartLoadWithRequest: PropTypes.func,
167-
168-
/**
169-
* Determines whether HTML5 videos play inline or use the native full-screen
170-
* controller.
171-
* default value `false`
172-
* **NOTE** : "In order for video to play inline, not only does this
173-
* property need to be set to true, but the video element in the HTML
174-
* document must also include the webkit-playsinline attribute."
175-
* @platform ios
176-
*/
177-
allowsInlineMediaPlayback: PropTypes.bool,
98+
...WebView.propTypes,
17899

179100
/**
180101
* Will be called once the message is being sent from webview

0 commit comments

Comments
 (0)