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.

Android rendering children of View as separate pages

See original GitHub issue

Summary

On Android, all children of children elements get rendered onto their own pages.

Environment info

info Fetching system and libraries information...
System:
    OS: macOS 10.15.5
    CPU: (16) x64 AMD Ryzen 7 1700X Eight-Core Processor         
    Memory: 166.43 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.18.0 - ~/.nvm/versions/node/v12.18.0/bin/node
    Yarn: 1.22.4 - ~/.nvm/versions/node/v12.18.0/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v12.18.0/bin/npm
  SDKs:
    iOS SDK:
      Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
  IDEs:
    Xcode: 11.5/11E608c - /usr/bin/xcodebuild
  npmPackages:
    react: 16.13.1 => 16.13.1 
    react-native: https://github.com/expo/react-native/archive/sdk-37.0.0.tar.gz => 0.61.4

Library version: Expo 37.0.0

Steps to reproduce

import ViewPager from "@react-native-community/viewpager"
import React from "react"
import { View, Text } from "react-native"

export const MyComponent = () => {
    return (
        <ViewPager initialPage={0}>
            <View key="1">
                <Text>First page a</Text>
                <Text>First page b</Text>
            </View>
            <View key="2">
                <Text>Second page a</Text>
                <Text>Second page b</Text>
            </View>
        </ViewPager>
    )
}

Renders incorrectly on Android. I have 4 screens here that I can swipe through, but I expect only 2 screens with text underneath.

WhatsApp Image 2020-06-21 at 15 05 35

Renders correctly on iOS, with the Text being underneath each other.

Screenshot 2020-06-21 at 15 05 04

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
troZeecommented, Jul 17, 2020

https://reactnative.dev/docs/view.html#collapsable

Views that are only used to layout their children or otherwise don’t draw anything may be automatically removed from the native hierarchy as an optimization. Set this property to false to disable this optimization and ensure that this View exists in the native view hierarchy.

@taingmeng you are right. Maybe we should consider to add this property by default.

1reaction
princefishthrowercommented, Sep 5, 2022

I didn’t have time to fight this but just to let anybody who reads this know, I switched to just basic screens with react-navigation and this half / incomplete navigation issue between screens went away.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Performance and view hierarchies - Android Developers
This page describes how to assess whether your view hierarchy is slowing your app down, and offers some strategies for addressing issues ...
Read more >
Custom View Components | Android Developers
Android offers a sophisticated and powerful componentized model for building your UI, based on the fundamental layout classes: View and ...
Read more >
Build a Responsive UI with ConstraintLayout
This page provides a guide to building a layout with ConstraintLayout in Android ... Each constraint represents a connection or alignment to another...
Read more >
Relative Layout | Android Developers
RelativeLayout lets child views specify their position relative to the parent view or to each other (specified by ID). So you can align...
Read more >
Layouts - Android Developers
All elements in the layout are built using a hierarchy of View and ViewGroup objects. A View usually draws something the user can...
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