Skip to content

[4.19.0] iOS custom header component weird positioning #3482

@efstathiosntonas

Description

@efstathiosntonas

Description

After upgrading to 4.19.0 the custom header component appears to be mis-positioned to the bottom right. Both on iOS 26.1 and 18.5 simulators.

Image Image
const NavigationHeader = ({
  color,
  component: Component,
  isWhite,
  text
}: {
  color?: string;
  component?: ComponentType<Record<string, never>> | null;
  isWhite?: boolean;
  text: string;
}) => {
  const { styles } = useStyles(stylesheet);

  if (Component) {
    return <Component />;
  }

  return (
    <CustomHeader
      hx="h5"
      style={styles.text(text.length, isWhite, color)}
      testID="navigation-header"
      weight="b"
    >
      {text}
    </CustomHeader>
  );
};

const stylesheet = createStyleSheet((theme) => ({
  text: (textLength: number, isWhite?: boolean, color?: string) => ({
    color: color || (isWhite ? '#FFFFFF' : theme.colors.neutrals_1100),
    fontSize: fontSize(textLength > 22 ? 16 : 20)
  })
}));

export default NavigationHeader;
  useLayoutEffect(() => {
    navigation.setOptions({
      headerLeft: () => (
        <BackButtonHeader
          disabled={logoutLoading || profileDeleteLoading}
          onPress={() => navigation.goBack()}
        />
      ),

      headerTitle: () => (
        <NavigationHeader
          text={t({ message: 'Settings', context: 'navigation_header' })}
        />
      )
    });
  }, [t, profileDeleteLoading, logoutLoading, navigation]);
   <IndexStack.Screen
          getComponent={() => Settings}
          name="Settings"
          options={{
            headerBackButtonDisplayMode: 'minimal',
            headerBackVisible: false,
            headerLeft: undefined,
            headerStyle: { backgroundColor: theme.colors.neutrals_0 },
            headerTitleAlign: 'center',
            title: ''
          }}
        />

If i do not use the useLayoutEffect and add title and BackButtonHeader on the stack options everything is fine:

   <IndexStack.Screen
          getComponent={() => Settings}
          name="Settings"
          options={{
            headerBackButtonDisplayMode: 'minimal',
            headerBackVisible: false,
            headerLeft: () => <BackButtonHeader />,
            headerStyle: { backgroundColor: theme.colors.neutrals_0 },
            headerTitleAlign: 'center',
            title: 'Settings'
          }}
        />
Image

Steps to reproduce

read above

Snack or a link to a repository

sorry,no snack but it's very easy to reproduce

Screens version

4.19.0

React Native version

0.81.5

Platforms

iOS

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

Metadata

Metadata

Assignees

Labels

Missing reproThis issue need minimum repro scenarioPlatform: iOSThis issue is specific to iOS

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions