React-native-tab-view: The prop initialLayout.height is marked as required in TabView, but its value is undefined

Created on 21 Jan 2019  路  2Comments  路  Source: satya164/react-native-tab-view

Current behaviour

Warning: Failed prop type: The prop initialLayout.height is marked as required in TabView, but its value is undefined. in TabView (at Dashboard.js:23)

Warning: Failed prop type: The prop layout.height is marked as required in TabBar, but its value is undefined. in TabBar (at TabView.js:59) in TabView (at Dashboard.js:23)

Warning: Failed prop type: The prop layout.height is marked as required in PagerAndroid, but its value is undefined. in PagerAndroid (at TabView.js:60) in TabView (at Dashboard.js:23)

Expected behaviour

No warnings

Code sample

import React, { Component } from "react";
import { View, StyleSheet, Dimensions } from "react-native";
import { TabView, TabBar, SceneMap } from "react-native-tab-view";

const FirstRoute = () => (
  <View style={[styles.scene, { backgroundColor: "#ff4081" }]} />
);
const SecondRoute = () => (
  <View style={[styles.scene, { backgroundColor: "#673ab7" }]} />
);

export default class DashBoard extends Component {
  state = {
    index: 0,
    routes: [
      { key: "first", title: "PR脫XIMOS 7 DIAS" },
      { key: "second", title: "TODOS REGISTROS" }
    ]
  };

  render() {
    return (
      <TabView
        navigationState={this.state}
        renderScene={SceneMap({
          first: FirstRoute,
          second: SecondRoute
        })}
        onIndexChange={index => this.setState({ index })}
        initialLayout={{ width: Dimensions.get("window").width }}
      />
    );
  }
}

const styles = StyleSheet.create({
  scene: {
    flex: 1
  }
});

What have you tried

I've just copy the exemple from Readme.md

Your Environment

React Native Environment Info:
    System:
      OS: Linux 4.19 Manjaro Linux undefined
      CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
      Memory: 217.85 MB / 7.58 GB
      Shell: 4.4.23 - /bin/bash
    Binaries:
      Node: 11.6.0 - /usr/local/bin/node
      Yarn: 1.13.0 - /usr/bin/yarn
      npm: 6.5.0-next.0 - /usr/local/bin/npm
    SDKs:
      Android SDK:
        API Levels: 23, 26, 27
        Build Tools: 26.0.2, 26.0.3, 27.0.3, 28.0.3
    npmPackages:
      react: 16.6.3 => 16.6.3 
      react-native: 0.57.8 => 0.57.8 

react-native-tab-view: "1.3.1",

Most helpful comment

Just modify initialLayout line to look like this:

initialLayout={{ width: Dimensions.get('window').width,height: Dimensions.get('window').height}}/>

It worked for me.

All 2 comments

Just modify initialLayout line to look like this:

initialLayout={{ width: Dimensions.get('window').width,height: Dimensions.get('window').height}}/>

It worked for me.

This should be fixed in the readme quickstart guide

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasonkw9 picture jasonkw9  路  3Comments

itzsaga picture itzsaga  路  3Comments

t3chnoboy picture t3chnoboy  路  3Comments

ios-dev-newbie picture ios-dev-newbie  路  3Comments

compojoom picture compojoom  路  4Comments