-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29756 from software-mansion-labs/ts-migration/Ren…
…derHTML [NO QA][TS migration] Migrate 'RenderHTML.js' component to TypeScript
- Loading branch information
Showing
1 changed file
with
4 additions
and
7 deletions.
There are no files selected for viewing
11 changes: 4 additions & 7 deletions
11
src/components/RenderHTML.js → src/components/RenderHTML.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,26 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
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 ( | ||
<RenderHTMLSource | ||
contentWidth={windowWidth * 0.8} | ||
source={{html: props.html}} | ||
source={{html}} | ||
/> | ||
); | ||
} | ||
|
||
RenderHTML.displayName = 'RenderHTML'; | ||
RenderHTML.propTypes = propTypes; | ||
RenderHTML.defaultProps = {}; | ||
|
||
export default RenderHTML; |