question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ViewPager Not Rendering

See original GitHub issue

Bug report

Summary

ViewPager is not getting rendered on the screen. Tried the code sample on this repo’s README but nothing is rendered on the screen but the text views i added. Tried applying height to the ViewPager but nothing changed.

The library is being used in an expo project.

Environment info

react-native info output:

System:
    OS: Windows 10 10.0.19041
    CPU: (4) x64 Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
    Memory: 6.54 GB / 15.91 GB
  Binaries:
    Node: 12.16.0 - ~\AppData\Local\Temp\yarn--1595620445087-0.5604080445455797\node.CMD
    Yarn: 1.22.4 - ~\AppData\Local\Temp\yarn--1595620445087-0.5604080445455797\yarn.CMD
    npm: 6.14.2 - ~\AppData\Roaming\npm\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: 9.0.4 - C:\Program Files\Java\jdk-9.0.4\bin\javac.EXE
    Python: 3.8.0 - D:\Applications\Python38-32\python.EXE
  npmPackages:
    @react-native-community/cli: Not Found
    react: ~16.11.0 => 16.11.0
    react-native: https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz => 0.62.2
  npmGlobalPackages:
    *react-native*: Not Found
Done in 4.30s.

Library version: 4.1.1

Also tried with version 3.3 which got installed by running expo install @react-native-community/viewpager. Since that didn’t work, then tried with v4.1.1

Tested the app on an Android device running Android version 9 through the Expo Client App.

Steps to reproduce

  1. Create a new component from the code below
  2. Use that component in App.tsx

Describe what you expected to happen:

  1. ViewPager is not being rendered
  2. The text Begin and End appear one below the other without the ViewPager being rendered in between the text views.

Reproducible sample code

import React from 'react';
import { View, Text, StyleSheet, SafeAreaView, StatusBar } from 'react-native';
import ViewPager from '@react-native-community/viewpager';

export const WelcomeScreen = () => {
	return (
		<SafeAreaView style={styles.container}>
			<Text>Begin</Text>

			<ViewPager style={styles.viewPager} initialPage={0}>
				<View style={{ height: 200 }} key="1">
					<Text>First page</Text>
				</View>
				<View key="2">
					<Text>Second page</Text>
				</View>
			</ViewPager>

			<Text>End</Text>
		</SafeAreaView>
	);
};

const styles = StyleSheet.create({
	container: {
		marginTop: StatusBar.currentHeight ? StatusBar.currentHeight : 0,
	},
	viewPager: {
		flex: 1,
		height: 500,
	},
});

Screenshot

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

20reactions
troZeecommented, Jul 27, 2020

Could you use below styles for viewPager style ?

	viewPager: {
		width: "100%",
		height:"100%",
	},

ViewPager has some problems with flex: 1 value.

2reactions
mkurczewskicommented, Apr 8, 2022

Still no readme update, I lost my time on following the official examples that are just not working…

Read more comments on GitHub >

github_iconTop Results From Across the Web

ViewPager not showing anything - Stack Overflow
I am create view pager with custom view pager ...
Read more >
ViewPager Not Rendering · Issue #202 · callstack/react-native ...
ViewPager is not being rendered; The text Begin and End appear one below the other without the ViewPager being rendered in between the...
Read more >
Why is my viewpager not showing? - MSDN - Microsoft
Hi guys, I have a main activity that creates a fragment, which in turn has a TabLayout and a ViewPager in it. My...
Read more >
Android ViewPager with WRAPCONTENT height - Mobikul
Recently, while working with the ViewPager, I found out that sometimes the Android ViewPager with WRAPCONTENT height flag is not visible.
Read more >
ViewPager with FragmentPagerAdapter - CodePath Cliffnotes
Usage · Layout ViewPager · Define Fragments · Setup FragmentPagerAdapter · Apply the Adapter · Selecting or Getting the Page · Setup OnPageChangeListener....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found