How do I center the text for the header in the Navigation Container?

  javascript, react-native

I am trying to center the text for a header, but can’t seem to implement it. I am following a tutorial on this and even though I’m following it step-by-step the text is not aligning in the center. I want it to center as I will be using a backHeaderTitle using the useLayoutEffect to return to the previous screen. I would appreciate any help as I have been stuck for a few days on this.

import "react-native-gesture-handler";
import React from "react"; 
import { StyleSheet, Text, View } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/
import LoginScreen from "./screens/LoginScreen";

const Stack = createStackNavigator();
const globalScreenOptions = {
  headerStyle: {backgroundColor: "#2C6BED"},
  headerTitleStyle: {color: "white"},
  headerTintColor: "white",
export default function App() {
  return (
      <Stack.Navigator screenOptions={globalScreenOptions}>

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',

Source: Ask Javascript Questions