“Bereaksi dimensi asli” Kode Jawaban

Dimensi bereaksi asli

import { Dimensions } from 'react-native';

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

Bereaksi dimensi asli

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;
Salafi aabshar khan

Jawaban yang mirip dengan “Bereaksi dimensi asli”

Pertanyaan yang mirip dengan “Bereaksi dimensi asli”

Lebih banyak jawaban terkait untuk “Bereaksi dimensi asli” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya