How to set auto height for viewing using Navigator?

I use the default components: View and Navigator. I want to set automatic height for View and Navigator, but if there are no styles with height for View - Navigator does not display, as it is: absolute. If the specified component is Text in View - View get auot height from child Text component. And if I set the "height: auto" parameter for View, this property does not work.

    render() {
        return (
            <View style={{height: 'auto', backgroundColor: 'powderblue'}}>
                <Navigator
                    initialRoute={{ title: 'My Initial Scene', index: 0 }}
                    renderScene={(route, navigator) => {
                        return (
                            <MyScene
                                title={route.title}
                            />
                        )
                    }

                    }
                />
            </View>
        )
    }
Run codeHide result
+4
source share
1 answer

style={{height:'auto'}}will not work. You must use an integer or use flex. Here you can see an example of parameters.

https://facebook.imtqy.com/react-native/docs/height-and-width.html

:

render() {
        return (
            <View style={{flex:1, backgroundColor: 'powderblue'}}>
                <Navigator
                    style={{flex:1}}
                    initialRoute={{ title: 'My Initial Scene', index: 0 }}
                    renderScene={(route, navigator) => {
                        return (
                            <MyScene
                                title={route.title}
                            />
                        )
                    }

                    }
                />
            </View>
        )
    }
+5

Source: https://habr.com/ru/post/1654986/


All Articles