From 2ddbe03d26fb543e7a16970ff7664865c8890c62 Mon Sep 17 00:00:00 2001 From: Nikolay Dombrovskiy <ndividl@gmail.com> Date: Mon, 18 Oct 2021 11:47:15 +0700 Subject: [PATCH] Implemented ViewPropTypes for web That fix "Cannot read property 'style' of undefined" error for web --- HTMLView.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/HTMLView.js b/HTMLView.js index 43f8b7e..322f128 100644 --- a/HTMLView.js +++ b/HTMLView.js @@ -1,7 +1,11 @@ import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; import htmlToElement from './htmlToElement'; -import {Linking, Platform, StyleSheet, View, ViewPropTypes} from 'react-native'; +import {Linking, Platform, StyleSheet, View, ViewPropTypes as RNViewPropTypes} from 'react-native'; + +const ViewPropTypes = typeof document !== 'undefined' || Platform.OS === 'web' + ? PropTypes.shape({style: PropTypes.object}) + : RNViewPropTypes || View.propTypes; const boldStyle = {fontWeight: 'bold'}; const italicStyle = {fontStyle: 'italic'};