Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Get React Native View width and height

import React from 'react'
import { View } from 'react-native'

export default function index() {
  const onLayout=(event)=> {
    const {x, y, height, width} = event.nativeEvent.layout;
    
  }
  return (
    <View onLayout={onLayout}>
      <OtherComponent />
    </View>
  )
}
Comment

Get size of a View in React Native

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Image
} from 'react-native';

export default class Comp extends Component {

  find_dimesions(layout){
    const {x, y, width, height} = layout;
    console.warn(x);
    console.warn(y);
    console.warn(width);
    console.warn(height);
  }
  render() {
    return (
      <View onLayout={(event) => { this.find_dimesions(event.nativeEvent.layout) }} style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.android.js
        </Text>
        <Text style={styles.instructions}>
          Double tap R on your keyboard to reload,{'
'}
          Shake or press menu button for dev menu
        </Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('Comp', () => Comp);
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery ui timepicker 
Javascript :: js in_array 
Javascript :: wait for promise javascript 
Javascript :: TYPING TEXT USING JS 
Javascript :: run javascript in html 
Javascript :: chrome storage set example 
Javascript :: nodejs http get request to external server 
Javascript :: chart js two layer label 
Javascript :: window.scrollTo Id sample code 
Javascript :: nextjs docs 
Javascript :: jquery class selector 
Javascript :: data types in javascript 
Javascript :: Cannot use import statement inside the Node.js REPL, alternatively use dynamic import 
Javascript :: js change h 
Javascript :: Round date to future 5min 
Javascript :: what does document.getelementbyid return 
Javascript :: export component react 
Javascript :: es6 functions 
Javascript :: nodejs exit code 
Javascript :: axios response.json 
Javascript :: vuex getters 
Javascript :: reverse js 
Javascript :: children javascript 
Javascript :: how to add items to object in javascript 
Javascript :: google jquery 3.5.1 
Javascript :: d3 not reading json 
Javascript :: angular img src binding 
Javascript :: vue js use component everywhere 
Javascript :: jquery plugin for searchable dropdown 
Javascript :: react js form radio input using hooks 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =