Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError with 'changeNavigationBarColor' in React Native & Hermes #66

Open
Senzo13 opened this issue Apr 7, 2024 · 2 comments
Open

Comments

@Senzo13
Copy link

Senzo13 commented Apr 7, 2024

Hello,

I've encountered a TypeError when trying to use react-native-navigation-bar-color in my React Native project. I'm not using Expo and my project is set up with the Hermes engine. Here's the error message I receive when I try to execute the code:
ERROR TypeError: Cannot read property 'changeNavigationBarColor' of null, js engine: hermes

Here's how I'm attempting to use the package in my component:

import React, { useEffect } from 'react';
import changeNavigationBarColor from 'react-native-navigation-bar-color';
import { useSettings } from '@context/settings.context'; // Assuming this is where theme.colors.primary is defined

const MyComponent = () => {
  const { theme } = useSettings();

  const changeColor = () => {
    changeNavigationBarColor(theme.colors.primary, true, true);
  };

  useEffect(() => {
      changeColor();
  }, []);

  return (
    // Component JSX
  );
};

export default MyComponent;

I've followed the installation instructions for react-native-navigation-bar-color and made sure everything is up to date. However, I'm still facing this issue. Could this be related to the Hermes engine, or is there something else I'm missing? Any guidance or assistance in resolving this error would be greatly appreciated.

I'm on React Native version "react-native": "^0.73.6".

Thank you in advance for your help.

@adriendomoison
Copy link

Same issue here ERROR TypeError: Cannot read property 'hideNavigationBar' of null

@gabrielpasini
Copy link

gabrielpasini commented Jun 17, 2024

Same error here!
ERROR TypeError: Cannot read property 'changeNavigationBarColor' of null

I tried to call changeNavigationBarColor as a Promise, like the tutorial, but this is not a promise. This error occurs in both cases.

I am on [email protected] with EXPO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants