React Native Tutorial #25 - Custom Header Component

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ต.ค. 2024

ความคิดเห็น • 156

  • @raphaelspitz3682
    @raphaelspitz3682 4 ปีที่แล้ว +53

    for the problem of heigth and witdht 100% just had in header.js :
    import React from 'react';
    import { StyleSheet, Text, View } from 'react-native';
    import { MaterialIcons } from '@expo/vector-icons';
    import { Dimensions } from 'react-native';
    export default function Header() {
    return (

    {/* icon for the menu */}
    GameZone

    )
    }
    const styles = StyleSheet.create({
    header: {
    width:Dimensions.get('screen').width,
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    },
    headerText: {
    fontWeight: 'bold',
    fontSize: 20,
    color: '#333',
    letterSpacing: 1,
    }
    });

    • @Bentengineering
      @Bentengineering 4 ปีที่แล้ว +4

      I left height: '100%' and this worked perfectly. Thank you!

    • @sim_scape
      @sim_scape 4 ปีที่แล้ว

      Perfect

    • @chengchao0311
      @chengchao0311 4 ปีที่แล้ว +11

      i added "width:Dimensions.get('screen').width" , but the position of header title appeared has a left padding on Android simulator. Then i fixed it by adding " headerTitleAlign: 'center' " for Home Screen navigationOptions.

    • @michaellesley2146
      @michaellesley2146 4 ปีที่แล้ว

      Obrigado!,

    • @r27td48
      @r27td48 4 ปีที่แล้ว

      Amazing advices, just a doubt, how can I change the side of the default arrow on the top? change the side of the arrow to go back to the previous page ...

  • @piusvictor8780
    @piusvictor8780 3 ปีที่แล้ว +1

    Your level of kungfu to break web concepts is more than awesome, am watching your tutorial while smiling, you deserve trillion subscribers. Be blessed man.

  • @maximebarber3780
    @maximebarber3780 4 ปีที่แล้ว +21

    Hey gang, here is a solution I implemented for React Navigation 5
    import React from 'react';
    import { createStackNavigator } from '@react-navigation/stack';
    import Home from '../screens/home';
    import ReviewDetails from '../screens/reviewDetails';
    import Header from '../shared/header';
    const homeStack = ({ navigation }) => {
    const Stack = createStackNavigator();
    return (
    ,
    }}
    />

    );
    };
    export default homeStack;

    • @Colstonewall
      @Colstonewall 4 ปีที่แล้ว

      Excellent, thank you!

    • @kaushikbhat6629
      @kaushikbhat6629 4 ปีที่แล้ว

      This works, thank you!

    • @RajarsheeChatterjee
      @RajarsheeChatterjee 4 ปีที่แล้ว

      ahh thanks man ^_^

    • @samanmanjoo3519
      @samanmanjoo3519 4 ปีที่แล้ว

      Thank you so much , it works!

    • @6av321
      @6av321 4 ปีที่แล้ว

      Thank you dude. I mean really. THANK YOUUUUUUUU :-*

  • @ImranSheikh-kg4qd
    @ImranSheikh-kg4qd 4 ปีที่แล้ว +54

    width: '100%' and height: '100%' not Working in the new version of React Navigation.
    But i manage to fix it ,
    add -- headerTitleAlign: "center" in "Home" Screen options (homeStack.js)
    then add height: '100%' this will fix height. {you can give a custom height value instead of these}.
    and width: Dimensions.get('window').width . Don't forget to import Dimensions from 'react-native'
    Note: this is a fix not a solution . This could break other thing . Share the real solution if you get it.

    • @lulzekontube3577
      @lulzekontube3577 4 ปีที่แล้ว +1

      I love you

    • @ruset-dewss4698
      @ruset-dewss4698 4 ปีที่แล้ว +1

      Your method solves the issue, there are obviously many methods but yours was the simplest and it Works!

    • @michaellesley2146
      @michaellesley2146 4 ปีที่แล้ว

      @@ruset-dewss4698 Obrigado!

    • @zeeshanalikhan8258
      @zeeshanalikhan8258 3 ปีที่แล้ว

      yes exactly, i have created special component for width and height, and i exported them wherever i required it

    • @vivianeb90
      @vivianeb90 2 ปีที่แล้ว

      Has this been fixed in newer versions of react navigator? Because I am using version 6 and having the issue that my whole custom nav component inside header is shifted towards the right by about 5-10 pixels and I have no idea why because I have the same exact component outside my header as comparison and it shows as it should, no styling difference. So I think that it must come from some defaults in header styles that I don't understand yet.

  • @joeuser9690
    @joeuser9690 4 ปีที่แล้ว +2

    For those of you doing this in React Navigation 5 here is the way I used the Header component on the homeStack: }} />

    • @robinware77
      @robinware77 4 ปีที่แล้ว

      reactnavigation.org/docs/headers/#setting-the-header-title here is the link to the documentation in case anyone wants to read it.

    • @lawp3537
      @lawp3537 2 ปีที่แล้ว

      Thank you, I was look for this

  • @cedrickvstheworld1810
    @cedrickvstheworld1810 4 ปีที่แล้ว +1

    I can actually create a production grade mobile app from here! Thanks man!

  • @DionnyPrensa
    @DionnyPrensa 4 ปีที่แล้ว +1

    You can use the HOC withNavigation. This HOC "inject" the navigation prop from the nearest parent.
    import {withNavigation} from "react-navigation";
    function Header({navigation}) {}
    export default withNavigation(MyHeader);
    You don't need pass the navigation prop for every child or grandson

    • @akash-kumar737
      @akash-kumar737 4 ปีที่แล้ว

      Thanks 😊. Need to install another package for v5.

  • @danielstoicamusic
    @danielstoicamusic 4 ปีที่แล้ว +1

    Welcome back, Shaun!
    Question for you: where can we find more info about this solution (and maybe other solutions) for giving the custom header access to navigation?
    Also, would this have worked by using withNavigation somehow?

  • @wilsoncardoso150
    @wilsoncardoso150 2 ปีที่แล้ว +2

    The latest version of DrawerNavigator already comes with a header and a burger menu icon.

  • @pratp3889
    @pratp3889 4 ปีที่แล้ว +3

    i like this tutorial, but please mention the version of package you install so that we can still create app as mentioned in course without any version issues in future. :)

  • @theweebdev
    @theweebdev 4 ปีที่แล้ว

    Finally! I've been waiting for this since last year. Thanks and you are awesome!

  • @MustafaAgaDev
    @MustafaAgaDev 4 ปีที่แล้ว +2

    Here is my workaround about the header style:
    import React from 'react'
    import { View, StyleSheet, Text, Dimensions } from 'react-native';
    import {MaterialIcons} from '@expo/vector-icons';
    export default function Header({navigation, title}) {
    const openMenu =()=>{
    navigation.openDrawer();
    }
    return (




    {title}



    )
    }
    const styles = StyleSheet.create({
    header: {
    width:Dimensions.get('screen').width,
    height: '100%',
    flexDirection: 'row',
    flex:1,
    alignItems: 'center',
    },
    headerText: {
    fontWeight: 'bold',
    fontSize: 20,
    color: '#333',
    letterSpacing: 1,
    height: '100%',
    alignItems:"center",
    },
    icon: {
    position: 'relative',
    flexDirection:'column',
    flex:0.5
    }
    });

    • @chengchao0311
      @chengchao0311 4 ปีที่แล้ว +2

      i added "width:Dimensions.get('screen').width" , but the position of header title appeared has a left padding on Android simulator. Then i fixed it by adding " headerTitleAlign: 'center' " for Home Screen navigationOptions.

    • @luisguillermo8375
      @luisguillermo8375 4 ปีที่แล้ว +3

      By any chance do you have the code for homeStack.js? I'm having problems opening the drawer function with the icon, and I think it has something to do with headerTitle:

    • @zuhryfayesz-me6uy
      @zuhryfayesz-me6uy 4 ปีที่แล้ว +1

      This worked for me for my iPhone 11 expo UI .. Thanks ..

  • @r27td48
    @r27td48 4 ปีที่แล้ว +1

    Amazing advices, just a doubt, how can I change the side of the default arrow on the top? change the side of the arrow to go back to the previous page ...

  • @muhammadzulqarnan533
    @muhammadzulqarnan533 3 ปีที่แล้ว

    if header background color not fill ..then check you have already set background color in
    homeStack.js
    defaultNavigationOptions:{
    headerTintColor:'#444',
    headerStyle:
    { backgroundColor:'red', height:60 }
    }

  • @SaintPepsiSanCoca
    @SaintPepsiSanCoca 4 ปีที่แล้ว +2

    Does your app crash? changing `width:100%, height:100%` to `flex:1` fixed it for me.

  • @VS257
    @VS257 3 ปีที่แล้ว +3

    What if u already have a burger icon for the drawer? The new React navigation has both the stack and drawer header on top of each other! Please help!

    • @ojitelikenechukwu3895
      @ojitelikenechukwu3895 2 ปีที่แล้ว

      hi, were you able to find your way around this.....kindly assist if you can

    • @filankzahmoul3494
      @filankzahmoul3494 2 ปีที่แล้ว

      @@ojitelikenechukwu3895 you need to add screenOptions={{ headerShown: false }}

    • @ojitelikenechukwu3895
      @ojitelikenechukwu3895 2 ปีที่แล้ว +1

      @@filankzahmoul3494 thank you, il try this out and revert🙌

    • @ojitelikenechukwu3895
      @ojitelikenechukwu3895 2 ปีที่แล้ว

      it worked....thanks

  • @techtian4351
    @techtian4351 4 ปีที่แล้ว

    bro, where were you? missed your tuts, glad you're back

  • @jonathanhirshowitz722
    @jonathanhirshowitz722 4 ปีที่แล้ว

    header won't be centered, but at least the icon and header won't be stacked and the solution is
    a lot simpler. just remove several styling rules:
    const styles = StyleSheet.create({
    header: {
    flexDirection: 'row'
    },
    headerText: {
    fontWeight: 'bold',
    fontSize: 20,
    color: '#333',
    letterSpacing: 1
    }
    })

  • @harikaprasanna
    @harikaprasanna 4 ปีที่แล้ว

    hey thanks alot ,i have solved my navigation issue ...12:10 good explaination...

  • @pauliusgaizauskas7416
    @pauliusgaizauskas7416 4 ปีที่แล้ว +3

    full solution with React Navigation 5, and hooks:
    github.com/Paulius11/reactNativeTutorial/tree/lesson-25

  • @mahdinevisandeh833
    @mahdinevisandeh833 ปีที่แล้ว

    In react navigation V.6 it automatically adds the menu icon and there's no need to go all this long way just to open drawer with a button. Though it's understandable that this video is for almost 3 years ago and so, I don't mean that it's Mr Shaun's fault!

  • @kensyjolicoeur
    @kensyjolicoeur 4 ปีที่แล้ว +1

    I like this one "we are going to do that in a second".

  • @MrBibipkins
    @MrBibipkins 4 ปีที่แล้ว +13

    setting width and height to 100% does not make header to take all the space. does anyone have the same problem? expo sdk-36

    • @skomsdungeon
      @skomsdungeon 4 ปีที่แล้ว

      I have the same problem :( anyone got a solution for this?

    • @andriiielagin2243
      @andriiielagin2243 4 ปีที่แล้ว

      And I have the same issue

    • @andriiielagin2243
      @andriiielagin2243 4 ปีที่แล้ว +1

      @@skomsdungeon It is possible to add left margin to the headerText style, for example marginLeft: 60

    • @raphalugs
      @raphalugs 4 ปีที่แล้ว +5

      If you want to center the headerText, you should go to homeStack.js and after headerStyle you put this headerTitleAlign: "center" (do as the same in aboutStack.js). But I don't know how to put the hamburger icon to left of the screen. Until now, I haven't solved the 100% dimensions problem :/

    • @ДмитрийИванов-з8з2м
      @ДмитрийИванов-з8з2м 4 ปีที่แล้ว

      windows or mac os ?

  • @kensyjolicoeur
    @kensyjolicoeur 4 ปีที่แล้ว

    at 3:27 set { flex:1 } to make it fill the header instead of { height:'100%' , width:'100%' }

    • @osamagamal495
      @osamagamal495 4 ปีที่แล้ว

      still doesn't work, the header doesn't take the whole space.

    • @osamagamal495
      @osamagamal495 4 ปีที่แล้ว

      can You send snippet of the code?

    • @ImranSheikh-kg4qd
      @ImranSheikh-kg4qd 4 ปีที่แล้ว

      @@osamagamal495 flex:1 - - not working for me also

    • @osamagamal495
      @osamagamal495 4 ปีที่แล้ว

      ​@@ImranSheikh-kg4qd Yes. I think the problem isn't related to the code, It has something to do with installed packages, because I cloned his Github link, and It works perfectly fine.

    • @ImranSheikh-kg4qd
      @ImranSheikh-kg4qd 4 ปีที่แล้ว

      @@osamagamal495 yes,Its happening for the New Version of React Navigation

  • @silviovieira7724
    @silviovieira7724 4 ปีที่แล้ว +1

    Please, sir, show us what is the best way to solve the width/heigh problem.

  • @robsonsilv4.
    @robsonsilv4. 4 ปีที่แล้ว +1

    If someone have problems with configuration, try to stick using lib versions same as the course, like expo 35 e etc. I'm having to fix some major problems on actual versions.

  • @aldodoohan7917
    @aldodoohan7917 4 ปีที่แล้ว +1

    hello guys , maybe for you who just watching this recently will find that your title and icon are not on the right place , so i've been looking for the answer and i finally fix this . First i will copy Mykhailo Stepanov comment , you should change your navigationOptions on your home/aboutStack with this navigationOptions: ({ navigation }) => {
    return {
    header: () =>
    }
    }
    and the second is , move your styles.header into your inner view , don't put styles.header as a wrapper(outer view) . Just adjust the rest , Goodluck
    #note ,you should add background color on your wrapper

  • @asadabdulmajid6270
    @asadabdulmajid6270 4 ปีที่แล้ว +10

    My header is not going to the center.???

    • @abitcompanyco2873
      @abitcompanyco2873 4 ปีที่แล้ว

      The same happens to me. Please help me, how do I fix it?

    • @2h4d0wDK
      @2h4d0wDK 4 ปีที่แล้ว

      I have the same problem, seems like it's because some things were added to the later versions of the libraries since this video has come out/was filmed.
      I still haven't found a fix working yet.

    • @2h4d0wDK
      @2h4d0wDK 4 ปีที่แล้ว +7

      adding ´´ headerTitleAlign: "center" ´´ to defaultNavigationOptions in both aboutStack and homeStack seems to have fixed the centering of the title text for some.

    • @blumaa
      @blumaa 4 ปีที่แล้ว

      @Rex Otavotoma Just wanted to add that Rex's solution worked for me. Also, I forget to import { Dimensions } from 'react-native'. After I did this everything worked.

  • @張嘉達-c7x
    @張嘉達-c7x 4 ปีที่แล้ว

    instead of passing navigation object as props to Header, i use useNavigation() hook in Header Component, it still work perfectly. Does it make sense ?

  • @ahmaddawood9691
    @ahmaddawood9691 3 ปีที่แล้ว

    You r a Savior Ninja....you are on the top on many famous instructors at UDEMY ....Trust me
    T H A N K S

  • @charlescampista9384
    @charlescampista9384 3 ปีที่แล้ว

    What if I want the header to appear above the content, in a way I can see it through a transparent color, like a glass. Can I achieve such thing?

  • @tonikevo1333
    @tonikevo1333 3 ปีที่แล้ว

    My screen freezes when going from DrawerNavigation to About and back to Home. Is there any solution?

  • @pandaman6146
    @pandaman6146 4 ปีที่แล้ว

    The header's height and width do not behave normal.
    I used [header] instead of [headerTitle] in homeStack.js? Is it correct?
    const screen={
    Home:{
    screen:Home,
    navigationOptions:({navigation})=>({
    header:()=>
    })
    }
    }

  • @tubehelpr
    @tubehelpr 4 ปีที่แล้ว +2

    React-navigation V5 will not work with this, unfortunately. Great tutorial though!

  • @filankzahmoul3494
    @filankzahmoul3494 2 ปีที่แล้ว +3

    LATEST VERSION CODE 01/06/2022 --------->>>>>>>>
    THIS IS THE ABOUTSTACK FILE , JUST DO THE SAME IN HOMESTACK FILE
    import { createNativeStackNavigator } from '@react-navigation/native-stack'
    import Header from '../shared/Header'
    import About from '../screens/About'
    const Stack = createNativeStackNavigator()
    const AboutStack = ({ navigation }) => {
    return (
    ,
    }}
    />

    )
    }
    export default AboutStack
    AND THIS IS THE HEADER COMPONENT----------->>>>>>>>>>
    import React from 'react'
    import { View, Text, StyleSheet } from 'react-native'
    import { MaterialIcons } from '@expo/vector-icons'
    const Header = ({ navigation ,title}) => {
    const openMenu = () => {
    navigation.openDrawer()
    }
    return (



    {title}


    )
    }
    const styles = StyleSheet.create({
    header: {
    height: '100%',
    width: '100%',
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    },
    headerText: {
    fontWeight: 'bold',
    fontSize: 20,
    letterSpacing: 1,
    color: 'white',
    },
    icon: {
    position: 'absolute',
    left: 10,
    color: '#fff',
    },
    })
    export default Header

    • @ojitelikenechukwu3895
      @ojitelikenechukwu3895 2 ปีที่แล้ว

      ya a life saver

    • @Gamerfan2000
      @Gamerfan2000 2 ปีที่แล้ว +1

      Can you please explain when you said "DO ThE SAME FOR HOMESTACK"? Also, could you please post the code for App.js and Drawer.js. I'm having too much trouble getting the icon for opening to get to work.

  • @raihanuddin1167
    @raihanuddin1167 3 ปีที่แล้ว

    When I click 3 desh icon then left side show my component but my home component up thake mobile time then I don’t show properly how can solved it

  • @naveengoyal5243
    @naveengoyal5243 4 ปีที่แล้ว

    Finally......you are back again :)

  • @_BL4CKGaming
    @_BL4CKGaming 2 ปีที่แล้ว

    still can do that, combine drawer and stack navigation in latest version?

  • @ankitpradhan4183
    @ankitpradhan4183 4 ปีที่แล้ว

    No matter what I still do not get the openDrawer() to work. I am getting openDrawer from navigation in props, but still can not toggle it,.

  • @muftaut.8076
    @muftaut.8076 4 ปีที่แล้ว

    Brilliant job!!!

  • @TheNerdyDev
    @TheNerdyDev 4 ปีที่แล้ว

    2020 First Ninja Video. 😀

  • @100sainadh
    @100sainadh 4 ปีที่แล้ว +1

    In On Press hamburger it is not working and The alignment of header text not in the center.Please help me

    • @uicubes
      @uicubes 4 ปีที่แล้ว +2

      the alignment doesn't work with me

    • @100sainadh
      @100sainadh 4 ปีที่แล้ว

      @@uicubes headerText:{
      fontWeight:'bold',
      fontSize:20,
      color:'#333',
      letterSpacing:1,
      marginLeft:60
      }
      try with this .Atleast u may get somewhat better result.Keep MarginLeft:60

  • @khayryazzez
    @khayryazzez 4 ปีที่แล้ว

    how to change the color of the drawer background

  • @guymross
    @guymross 3 ปีที่แล้ว

    Thank you so much!

  • @muhammadzulqarnan533
    @muhammadzulqarnan533 3 ปีที่แล้ว

    in header Stylesheet width:'100%', height:100%' work fine ' for react-native cli version v4
    code is below
    const styles=StyleSheet.create({
    header:{

    width:'100%',
    // width:Dimensions.get('screen').width,
    height:'100%',

    flexDirection:'row',
    alignItems:'center',
    justifyContent:'center',
    // background color already set in defaultNavigationOptions no need here
    //backgroundColor:'red',
    },
    headerText:{
    fontWeight:'bold',
    fontSize:20,
    color:'#333',
    letterSpacing:1,
    }
    });

  • @abitcompanyco2873
    @abitcompanyco2873 4 ปีที่แล้ว

    The same happens to me that Asad Abdul. Please help me, how do I fix them?
    Thanks

  • @sarlaysid4830
    @sarlaysid4830 4 ปีที่แล้ว

    MaterialIcons didnt work for me (I dont know why) but I tried it with SimpleLineIcons and it worked

  • @wendybarrera3348
    @wendybarrera3348 4 ปีที่แล้ว

    how can i change the color of the header?

  • @milovanlacarak8959
    @milovanlacarak8959 3 ปีที่แล้ว +1

    not judging but I think you are making it less readable by passing objects instead of just using const DrawerName and then making a componenet, its much more presentable that way, Im learning React and most people probably look into docs, docs stick with the convention I stated the way you do it is just confusing for someone trying to learn it

  • @manoj-k
    @manoj-k 2 ปีที่แล้ว

    🔥🔥🔥

  • @thenoob8682
    @thenoob8682 3 ปีที่แล้ว

    you are the best

  • @arihanthirawat6574
    @arihanthirawat6574 4 ปีที่แล้ว

    please make a video on expo eject

  • @paristar3079
    @paristar3079 4 ปีที่แล้ว +1

    Where do you live in UK?

  • @swapnilsagar3805
    @swapnilsagar3805 3 ปีที่แล้ว

    If anyone has successfully implemented the project till here, can you provide your GitHub/code link.
    My drawer closes itself as soon as I leave the screen and the hamburger is also not working.

  • @thanhat5907
    @thanhat5907 4 ปีที่แล้ว

    The good tutorial but I have a problem. I have a mistake about auto alignItem center header "GameZone" so icon menu can't be on the left :(

    • @thanhat447
      @thanhat447 4 ปีที่แล้ว

      I met a problem too. My title 'GameZone' on the left with a menu icon.

  • @shamir-imtiaz
    @shamir-imtiaz 4 ปีที่แล้ว

    Hello sir. I want to learn android development. But which will be best for android: flutter or react native. I am very confused. Thank you for your suggestion.

    • @shamir-imtiaz
      @shamir-imtiaz 4 ปีที่แล้ว

      @@okradze thank you sir.For your suggestion.

    • @ImranSheikh-kg4qd
      @ImranSheikh-kg4qd 4 ปีที่แล้ว +1

      I know react previously .... I haven't find anything difficult still now.
      So if you absolutely new then try to find-out .
      if know react then react-native could be your choice.

    • @shamir-imtiaz
      @shamir-imtiaz 4 ปีที่แล้ว

      @@ImranSheikh-kg4qd Thank you bro. I am trying to learn flutter for android development. Thank you.

  • @salahalsamarraaee650
    @salahalsamarraaee650 2 ปีที่แล้ว

    thank you

  • @pramithwijethunga2161
    @pramithwijethunga2161 3 ปีที่แล้ว

    Plz sir can you do a modern react native tutorial with react-native cli..?? I learned a lot with the help of your tutorials. please be kind enough to consider my request.

  • @mrt2938
    @mrt2938 4 ปีที่แล้ว

    wont work with ios iphone notch though

  • @Isaac-xc2hc
    @Isaac-xc2hc 4 ปีที่แล้ว +2

    import React from 'react';
    import { StyleSheet, Text, View} from 'react-native';
    import { MaterialIcons } from '@expo/vector-icons';
    import { Dimensions } from 'react-native';
    export default function Header( {title,navigation} ) {
    const openMenu = () => {
    navigation.openDrawer();
    }
    return (

    {title}

    );
    }
    const styles = StyleSheet.create({
    header: {
    width:Dimensions.get('screen').width,
    height: '100%',
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    },
    headerText: {
    fontWeight: 'bold',
    fontSize: 20,
    color: '#fff',
    letterSpacing: 1,
    },
    icon: {
    position: 'absolute',
    left: 16,
    }
    });

  • @vijaytiwari826
    @vijaytiwari826 4 ปีที่แล้ว +6

    React Navigation v5.x
    // Changes in routes/homeStack.js
    import React from 'react';
    import { createStackNavigator } from '@react-navigation/stack';
    import { MaterialIcons } from '@expo/vector-icons';
    import Home from '../screens/home';
    import ReviewDetails from '../screens/reviewDetails';
    const { Navigator, Screen } = createStackNavigator();
    export const HomeStack = ({ navigation }) => {
    const openMenu = () => {
    navigation.openDrawer();
    }
    return (

    (

    ),
    headerLeftContainerStyle: {
    paddingHorizontal: 20,
    }
    }}
    />


    );
    };
    export default HomeStack;
    // Similar changes in routes/aboutStack.js

    • @emmuoriginals5296
      @emmuoriginals5296 3 ปีที่แล้ว +1

      Thanks my guy

    • @andressalomon6703
      @andressalomon6703 3 ปีที่แล้ว +1

      Thanks Vijay! This also worked in RN v6.x. I think is a great way of doing this custom header, as you don't need to create a new component.

  • @johncerpa3782
    @johncerpa3782 4 ปีที่แล้ว

    Welcome !!

  • @gokulkannan7883
    @gokulkannan7883 4 ปีที่แล้ว

    I am getting [X] icon instead of humburger icon

  • @paungster
    @paungster 5 หลายเดือนก่อน

    👏

  • @ahmedsarmoum2956
    @ahmedsarmoum2956 4 ปีที่แล้ว

    Thanks

  • @lglf77
    @lglf77 4 ปีที่แล้ว

    V5?

  • @NimaEsfahani
    @NimaEsfahani 2 ปีที่แล้ว

    🙂🙂

  • @alanfans6681
    @alanfans6681 4 ปีที่แล้ว

    谢谢

  • @robinware77
    @robinware77 4 ปีที่แล้ว

    reactnavigation.org/docs/headers/#setting-the-header-title here is an link to v5 just in case you want to documentation.

  • @petartodorov9202
    @petartodorov9202 4 ปีที่แล้ว

    JUNE 2020 FIX: (I didn't get any of the other suggestions to work for me). To align the menu icon and the title correctly, I simply dropped all styling on the header and added textAlign: 'center' to the headerText. Icon style should stay the same with absolute positioning but I added zIndex: 1, since otherwise it is left under the title and is untouchable :
    const styles = StyleSheet.create({
    header: {
    // width: Dimensions.get('screen').width,
    // height: '100%',
    // flexDirection: 'row',
    // alignItems: 'center',
    // justifyContent: 'center'
    },
    headerText: {
    fontWeight: 'bold',
    fontSize: 20,
    color: '#333',
    letterSpacing: 1,
    textAlign: 'center'
    },
    icon: {
    position: 'absolute',
    left: 16
    ,
    zIndex: 1
    }
    });

  • @skgamerff2073
    @skgamerff2073 2 ปีที่แล้ว

    Gu ohg

  • @raihanuddin1167
    @raihanuddin1167 3 ปีที่แล้ว

    Any one plz help me

  • @smartize
    @smartize 3 ปีที่แล้ว

    here is how to pass navigation prop to custom Header in React Navigation v5
    export default Navigator = (props) => {
    const { navigation } = props;
    return (


    }} />


    )
    }

  • @timzeynalov3537
    @timzeynalov3537 3 ปีที่แล้ว +1

    this fucking navigation does not work