Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions packages/react-native/Libraries/StyleSheet/StyleSheetExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand All @@ -13,16 +13,10 @@
import type {____Styles_Internal} from './StyleSheetTypes';

import composeStyles from '../../src/private/styles/composeStyles';
import ReactNativeStyleAttributes from '../Components/View/ReactNativeStyleAttributes';
import flatten from './flattenStyle';

const ReactNativeStyleAttributes =
require('../Components/View/ReactNativeStyleAttributes').default;
const PixelRatio = require('../Utilities/PixelRatio').default;

let hairlineWidth: number = PixelRatio.roundToNearestPixel(0.4);
if (hairlineWidth === 0) {
hairlineWidth = 1 / PixelRatio.get();
}
let _hairlineWidth: ?number;

const absoluteFill = {
position: 'absolute',
Expand Down Expand Up @@ -95,7 +89,18 @@ export default {
*
* A line with hairline width may not be visible if your simulator is downscaled.
*/
hairlineWidth,
// $FlowFixMe[unsafe-getters-setters] - Lazily import dependencies.
get hairlineWidth(): number {
if (_hairlineWidth == null) {
const PixelRatio = require('../Utilities/PixelRatio').default;

_hairlineWidth = PixelRatio.roundToNearestPixel(0.4);
if (_hairlineWidth === 0) {
_hairlineWidth = 1 / PixelRatio.get();
}
}
return _hairlineWidth;
},

/**
* A very common pattern is to create overlays with position absolute and zero positioning,
Expand Down
Loading