Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
React Native: la vista no cubre la altura de los padres

Tema

Hay 2 pestañas apiladas horizontalmente y en la primera pestaña, la vista en color verde no puede llenar la altura de los padres cuando el contenido es diferente en ambas pestañas .

ingrese la descripción de la imagen aquí

Reproducible en Expo

https://snack.expo.dev/@vinay-sharma/92706e

Código

 import React from "react"; import { Text, View } from "react-native"; const Tab = ({ textNodes }) => { return ( <View style={{ flex: 1, backgroundColor: "red" }}> <View style={{ flexDirection: "row" }}> <View style={{ backgroundColor: "blue", width: 10 }}></View> {/* the green view isn't able to fill parent's height*/} <View style={{ backgroundColor: "green", flex: 1 }}> {textNodes.map((node) => ( <Text>{node}</Text> ))} </View> </View> <View style={{ height: 10, backgroundColor: "black" }} /> </View> ); }; export default function App() { return ( <View style={{ flexDirection: "row", marginTop: 25 }}> <Tab textNodes={[1, 2, 3]} /> <Tab textNodes={[1, 2, 3, 4]} /> </View> ); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Simplemente agregue la altura de la propiedad de style height: '100%' en la vista de row en su función Tab()

El primer elemento no toma el 100% de la altura porque tiene menos Childs (comportamiento predeterminado de View , doc )

 import React from 'react'; import { Text, View } from 'react-native'; const Tab = ({ textNodes }) => { return ( <View style={{ flex: 1, backgroundColor: 'red' }}> <View style={{ flexDirection: 'row', height: '100%' }}> //here add height 100% <View style={{ backgroundColor: 'blue', width: 10 }}></View> {/* the green view isn't able to fill parent's height*/} <View style={{ backgroundColor: 'green', flex: 1 }}> {textNodes.map((node)=><Text>{node}</Text>)} </View> </View> <View style={{ height: 10, backgroundColor: "black" }} /> </View> ) } export default function App() { return ( <View style={{ flexDirection: 'row', marginTop: 25 }}> <Tab textNodes={[1, 2, 3]} /> <Tab textNodes={[1, 2, 3, 4]} /> </View> ); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!