react-native-status-bar-size icon indicating copy to clipboard operation
react-native-status-bar-size copied to clipboard

StatusBarSizeIOS.currentHeight === null ?

Open pavlelekic opened this issue 9 years ago • 5 comments
trafficstars

Hi, I have some issues getting the status bar size, in getInitialState() I get null when calling StatusBarSizeIOS.currentHeight.

Also, if I do device rotate left nothing will trigger, but then when I do device rotate right I get a 'willChange' event, and the value I get is 0, which is wrong completely.

So basically, I cannot get status bar size at all, and in rare occasions when I do get a value- it's wrong.

pavlelekic avatar May 13 '16 07:05 pavlelekic

Btw, these are my dependencies from package.json

  "dependencies": {
    "react": "^0.14.7",
    "react-native": "^0.25.1",
    "react-native-shake-event-ios": "^1.0.3"
  },

The code is the same as your example, I just copy & pasted it from your README.md

pavlelekic avatar May 13 '16 09:05 pavlelekic

@pavlelekic I get the same null value for the height.

Did you manage to solve this? Though I got the react-native-status-bar-height package showing the correct height for me.

narek11 avatar Oct 17 '17 11:10 narek11

@narek11 FYI that package is no better than hardcoding a status bar height via a constant so I wouldn't use it. This package actually listens to status bar frame changes sent from the native side.

With that said, it seems flaky right now. I get null, 0, 20 randomly.

Naoto-Ida avatar Nov 23 '17 15:11 Naoto-Ida

If you're looking for just the height of the header, you can do

import { NativeModules } from 'react-native';
const { StatusBarManager } = NativeModules;

  StatusBarManager.getHeight(
    (statusBarFrameData) => {
      console.log(statusBarFrameData.height);
    }
  );

ErkanSensei avatar Feb 03 '18 22:02 ErkanSensei

Any way to listen to the StatusBar height change using StatusBarManager?

Waltari10 avatar May 10 '18 05:05 Waltari10