Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit e700483

Browse files
committed
get height and width inside the fuction call
1 parent d37dedd commit e700483

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/index.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,20 @@
2222
* SOFTWARE.
2323
*/
2424

25-
import {
26-
Dimensions
27-
} from 'react-native';
25+
import { Dimensions } from "react-native";
2826

29-
const {height, width} = Dimensions.get('window');
30-
31-
export const responsiveHeight = (h) => {
32-
return height*(h/100);
27+
export const responsiveHeight = h => {
28+
const { height } = Dimensions.get("window");
29+
return height * (h / 100);
3330
};
3431

35-
export const responsiveWidth = (w) => {
36-
return width*(w/100);
32+
export const responsiveWidth = w => {
33+
const { width } = Dimensions.get("window");
34+
return width * (w / 100);
3735
};
3836

39-
export const responsiveFontSize = (f) => {
40-
const tempHeight = (16/9)*width;
41-
return Math.sqrt(Math.pow(tempHeight, 2) + Math.pow(width, 2))*(f/100);
37+
export const responsiveFontSize = f => {
38+
const { width } = Dimensions.get("window");
39+
const tempHeight = (16 / 9) * width;
40+
return Math.sqrt(Math.pow(tempHeight, 2) + Math.pow(width, 2)) * (f / 100);
4241
};

0 commit comments

Comments
 (0)