From 7b277a636b6e04c76926d276100a0344e00ddaef Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Tue, 17 Oct 2023 14:05:24 +0200 Subject: [PATCH 1/2] [TS migration] Migrate 'RenderHTML.js' component to TypeScript --- src/components/{RenderHTML.js => RenderHTML.tsx} | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) rename src/components/{RenderHTML.js => RenderHTML.tsx} (75%) diff --git a/src/components/RenderHTML.js b/src/components/RenderHTML.tsx similarity index 75% rename from src/components/RenderHTML.js rename to src/components/RenderHTML.tsx index d2d4f0b58e71..14423d5e9d26 100644 --- a/src/components/RenderHTML.js +++ b/src/components/RenderHTML.tsx @@ -1,29 +1,26 @@ import React from 'react'; -import PropTypes from 'prop-types'; import {RenderHTMLSource} from 'react-native-render-html'; import useWindowDimensions from '../hooks/useWindowDimensions'; -const propTypes = { +type RenderHTMLProps = { /** HTML string to render */ - html: PropTypes.string.isRequired, + html: string; }; // We are using the explicit composite architecture for performance gains. // Configuration for RenderHTML is handled in a top-level component providing // context to RenderHTMLSource components. See https://git.io/JRcZb // The provider is available at src/components/HTMLEngineProvider/ -function RenderHTML(props) { +function RenderHTML({html}: RenderHTMLProps) { const {windowWidth} = useWindowDimensions(); return ( ); } RenderHTML.displayName = 'RenderHTML'; -RenderHTML.propTypes = propTypes; -RenderHTML.defaultProps = {}; export default RenderHTML; From abad73ff87fd544d75c4b4def30722d9e454766b Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Tue, 17 Oct 2023 15:05:58 +0200 Subject: [PATCH 2/2] fix TS check --- src/hooks/useWindowDimensions/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/hooks/useWindowDimensions/index.js b/src/hooks/useWindowDimensions/index.js index 1a1f7eed5a67..404bbd161a8c 100644 --- a/src/hooks/useWindowDimensions/index.js +++ b/src/hooks/useWindowDimensions/index.js @@ -2,9 +2,19 @@ import {Dimensions, useWindowDimensions} from 'react-native'; import variables from '../../styles/variables'; +/** + * @typedef {Object} WindowDimensions + * @property {number} windowWidth + * @property {number} windowHeight + * @property {boolean} isExtraSmallScreenHeight + * @property {boolean} isSmallScreenWidth + * @property {boolean} isMediumScreenWidth + * @property {boolean} isLargeScreenWidth + */ + /** * A convenience wrapper around React Native's useWindowDimensions hook that also provides booleans for our breakpoints. - * @returns {Object} + * @returns {WindowDimensions} */ export default function () { const {width: windowWidth, height: windowHeight} = useWindowDimensions();