-
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 #26543 from tamdao/26071-image-load
Fix image loads on resize window
- Loading branch information
Showing
3 changed files
with
40 additions
and
28 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/components/Attachments/AttachmentCarousel/AttachmentCarouselCellRenderer.js
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {View, PixelRatio} from 'react-native'; | ||
import useWindowDimensions from '../../../hooks/useWindowDimensions'; | ||
import styles from '../../../styles/styles'; | ||
|
||
const propTypes = { | ||
/** Cell Container styles */ | ||
style: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]), | ||
}; | ||
|
||
const defaultProps = { | ||
style: [], | ||
}; | ||
|
||
function AttachmentCarouselCellRenderer(props) { | ||
const {windowWidth, isSmallScreenWidth} = useWindowDimensions(); | ||
const modalStyles = styles.centeredModalStyles(isSmallScreenWidth, true); | ||
const style = [props.style, styles.h100, {width: PixelRatio.roundToNearestPixel(windowWidth - (modalStyles.marginHorizontal + modalStyles.borderWidth) * 2)}]; | ||
|
||
return ( | ||
<View | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
style={style} | ||
/> | ||
); | ||
} | ||
|
||
AttachmentCarouselCellRenderer.propTypes = propTypes; | ||
AttachmentCarouselCellRenderer.defaultProps = defaultProps; | ||
AttachmentCarouselCellRenderer.displayName = 'AttachmentCarouselCellRenderer'; | ||
|
||
export default React.memo(AttachmentCarouselCellRenderer); |
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
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