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.

Percentage in styles causing Text components not to render

See original GitHub issue

Environment

React Native Environment Info: System: OS: macOS High Sierra 10.13.6 CPU: x64 Intel® Core™ i7-4960HQ CPU @ 2.60GHz Memory: 3.82 GB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 8.9.1 - /usr/local/bin/node Yarn: 1.10.1 - /usr/local/bin/yarn npm: 6.4.1 - /usr/local/bin/npm SDKs: iOS SDK: Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0 IDEs: Android Studio: 3.1 AI-173.4670197 Xcode: 10.0/10A255 - /usr/bin/xcodebuild npmPackages: react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728 react-native: 0.57.4 => 0.57.4 npmGlobalPackages: react-native-cli: 0.1.10 react-native-git-upgrade: 0.2.7

Description

For some reason, one of the Views I wrote that has a padding value of a percentage, 10%, any Text components inside the View is not shown. For some reason, only TouchableOpacity is rendered here:

Screenshot

edit: When I removed the padding value from that style, everything rendered as expected.

Reproducible Demo

<View style={{ backgroundColor: '#32bfca', padding: '10%'  }}>
  <Text style={{ marginVertical: 14 }}>Embark on a 30-day journey called {journey.JourneyName} that includes:</Text>
    {journey.games.map(gameId => (
      <Text key={gameId} style={{ fontFamily: 'Saira-SemiBold', marginBottom: 4 }}>• {Helper.assessObject(props.games.data, 'gameId', gameId).name}</Text>
    ))}
  <Text style={{ textAlign: 'center', marginTop: 12, marginBottom: 34 }}>All in just 15 mins a day!</Text>
  <TouchableOpacity onPress={() => {
    const type = props.journeys.currentJourney ? props.journeys.currentJourney.type : journey.type;
    props.goToJourney(type, props.navigator);
  }}>
    <View style={{ alignSelf: 'center', alignItems: 'center', justifyContent: 'center', width: 222, height: 40, borderRadius: 18, backgroundColor: 'white' }}>
      <Text>{props.journeys.currentJourney !== null ? 'CONTINUE JOURNEY' : 'START JOURNEY'}</Text>
    </View>
  </TouchableOpacity>
</View>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
hasnabbascommented, Dec 19, 2018

@dozel I used EStyleSheet instead. Regression seemed a little risky for me, given the stage of my project. It is closest solution you can to using percentage.

1reaction
JKCooper2commented, Nov 11, 2018

Hmm… I tried to reproduce with that code but no luck: https://snack.expo.io/@jkcooper/rn-view-percent. Can you try reverting to v0.57.0 to see if its a regression?

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-native view auto width by text inside
I have a view and text inside. The view in auto width doesn't resize by inherit text element. How to fix that issue...
Read more >
React native styling. width: percentage - number-Reactjs
Your code not working because, it's rendered then inputContainerWidth updated. To make it work, there should be another render with new inputContainerWidth ....
Read more >
Wrapping and breaking text - CSS: Cascading Style Sheets
This guide explains the various ways in which overflowing text can be managed in CSS.
Read more >
Content Jumping (and How To Avoid It)
The good news is that it's fixable. Luckily, modern browsers don't perform initial render until the style sheets have finished loading, which ...
Read more >
Understanding Success Criterion 1.4.4
1.4.4 Resize text: Except for captions and images of text, text can be ... is not required; truncation is acceptable if the component's...
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