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 :: use await in for each 
Javascript :: js add function to array 
Javascript :: jquery validation on click 
Javascript :: js var vs const 
Javascript :: use this inside a foreach 
Javascript :: angular autocomplete displaywith 
Javascript :: what is redis used for 
Javascript :: input in js 
Javascript :: jquery find table from td 
Javascript :: jquery get all classes of a div 
Javascript :: how to filter array in javascript 
Javascript :: slide hide animaition in react 
Javascript :: yup phone number validation 
Javascript :: javascript Set Intersection Operation 
Javascript :: remove specific item from array 
Javascript :: us postal code regex 
Javascript :: named regex group JS 
Javascript :: mongoose number bigger 
Javascript :: async wait for axios reactjs 
Javascript :: what is adapter.js 
Javascript :: comment in javascript 
Javascript :: ajouter javascript dans html 
Javascript :: mouse wheel event angular for table 
Javascript :: uuid in node js 
Javascript :: Function Alert,confirm,prompt 
Javascript :: Implement stack as an abstract data type using singly linked list and use this ADT for conversion of infix expression to postfix, prefix and evaluation of postfix and prefix expression. 
Javascript :: how to create a pop up in middle screen javascript 
Javascript :: how to use graphql api in react 
Javascript :: how to add lang attribute in next js 
Javascript :: javascript createelement innerhtml 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =