Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 additions & 19 deletions autoHeightWebView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ import {
shouldUpdate,
} from './utils';

const defaultProps = {
showsVerticalScrollIndicator: false,
showsHorizontalScrollIndicator: false,
originWhitelist: ['*'],
...(Platform.OS === 'android' ? { scalesPageToFit: false } : {}),
...(Platform.OS === 'ios' ? { viewportContent: 'width=device-width' } : {}),
};

const AutoHeightWebView = React.memo(
forwardRef((props, ref) => {
forwardRef((props = defaultProps, ref) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems having any one of the prop passed in will override all the defaultProps.

const {
style,
onMessage,
Expand Down Expand Up @@ -114,24 +122,6 @@ AutoHeightWebView.propTypes = {
source: PropTypes.object,
};

let defaultProps = {
showsVerticalScrollIndicator: false,
showsHorizontalScrollIndicator: false,
originWhitelist: ['*'],
};

Platform.OS === 'android' &&
Object.assign(defaultProps, {
scalesPageToFit: false,
});

Platform.OS === 'ios' &&
Object.assign(defaultProps, {
viewportContent: 'width=device-width',
});

AutoHeightWebView.defaultProps = defaultProps;

const styles = StyleSheet.create({
webView: {
backgroundColor: 'transparent',
Expand Down