GithubHelp home page GithubHelp logo

Comments (5)

svk31 avatar svk31 commented on April 18, 2024 1

Something like this:

image

I've continued playing around with this and I just managed to get it working, with the one issue still that the hamburger is misaligned, but that's probably just due to the component I'm using.

What I did was fetch react-navigation from github instead of using the version on npm, this fixed the header not appearing and also fixed the "header: left" property so the left button actually appears, as well as an issue with the drawer going behind the header.

The working approach I have right now looks something like this:

CompX.navigationOptions = {
        title: "CompX",
        header: ({ navigate }) => ({
            left: <Button transparent onPress={() => {navigate("DrawerOpen")}}><Icon name="ios-menu">    </Icon></Button>
        })
    };

NestedNavigator1 = StackNavigator({
    Screen1: {
        screen: Comp1
    },
    Screen2: {
        screen: Comp2
    }
})

NestedNavigator2 = StackNavigator({
    Screen3: {
        screen: Comp3
    },
    Screen4: {
        screen: Comp4
    }
})

Drawer = DrawerNavigator({
    SubNav1: {
        screen: NestedNavigator1
    },
    SubNav2: {
        screen: NestedNavigator2
    }
})

CompX without header property renders the back button as expected.

from react-navigation.

Steviey avatar Steviey commented on April 18, 2024

+1

from react-navigation.

hilkeheremans avatar hilkeheremans commented on April 18, 2024

I worked on this problem today, and the approach I came up with for now is to create a class factory function (~ HOC) that takes a component and renders the drawer header around it. To actually do it properly is a bit trickier since you will want to use navigationOptions etc.

I'll post a sample tomorrow (need to generalize it a little first).

from react-navigation.

satya164 avatar satya164 commented on April 18, 2024

What do you mean by a classical header? Do you have a mock-up or screenshot of what you want?

from react-navigation.

satya164 avatar satya164 commented on April 18, 2024

Yes, the left key inside navigationOptions.header is the correct way of doing it. And regarding misalignment, you'll likely need to fix it in your component.

from react-navigation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.