diff --git a/autoHeightWebView/index.js b/autoHeightWebView/index.js index 3d0dc75..e7b8b81 100644 --- a/autoHeightWebView/index.js +++ b/autoHeightWebView/index.js @@ -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) => { const { style, onMessage, @@ -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',