Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

dimensions react native

import { Dimensions } from 'react-native';

console.log({
	width: Dimensions.get('window').width,
	height: Dimensions.get('window').height
})
Comment

react native dimensions

import React, { useState, useEffect } from "react";
 import { View, StyleSheet, Text, Dimensions } from "react-native";
 const window = Dimensions.get("window");
 const screen = Dimensions.get("screen");
 const App = () => {
 const [dimensions, setDimensions] = useState({ window, screen });
 const onChange = ({ window, screen }) => {
     setDimensions({ window, screen });
   };
 useEffect(() => {
     Dimensions.addEventListener("change", onChange);
     return () => {
       Dimensions.removeEventListener("change", onChange);
     };
   });
 return (
   {<code>Window Dimensions: height - ${dimensions.window.height}, width - ${dimensions.window.width}}
   {Screen Dimensions: height - ${dimensions.screen.height}, width - ${dimensions.screen.width}}     
   );
  }
  const styles = StyleSheet.create({
   container: {
     flex: 1,
     justifyContent: "center",
     alignItems: "center"
   }
  });
  export default App;
Comment

react native dimensions

import { useWindowDimensions } from 'react-native';

const { height, width } = useWindowDimensions();
/* useWindowDimensions automatically updates 
   all of its values when screen size or font scale changes. */
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript open link in new tab 
Javascript :: angular valuechanges get id 
Javascript :: model show in jquery 
Javascript :: object json jquery foreach 
Javascript :: loop through object jquery 
Javascript :: javascript get element by class name 
Javascript :: jquery remove and add class 
Javascript :: fetch post json 
Javascript :: style.visibility javascript 
Javascript :: How do I get the number of days between two dates in JavaScript 
Javascript :: delay in javascript 
Javascript :: javascript remove extension from filename 
Javascript :: on mouse over in jquery 
Javascript :: react native duplicate resources: Android 
Javascript :: express req ip address 
Javascript :: authfunctions react 
Javascript :: node console log without newline 
Javascript :: js format number thousands separator 
Javascript :: prettier ignore line 
Javascript :: E: Unable to locate package nodejs 
Javascript :: create react project 
Javascript :: modal.show jquery 
Javascript :: vue 3 cdn 
Javascript :: automatically scroll to bottom of page 
Javascript :: node js remove html tags from string 
Javascript :: how to run vue js project on different port 
Javascript :: z index style javascript 
Javascript :: numero aleatorio js 
Javascript :: javascript listen for double click 
Javascript :: react native seperator code 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =