Error: JSON value of type NSstring cannot be converted of a YGValue. Did you forget the % or pt suffix

Viewed 5555

Why can't i use: global.App_BottomTabBarHeight below to set the height in React Navigation createBottomTabNavigator? Where global.App_BottomTabBarHeight = '8%'. This is defined in another class. I'm developing an iOS app with 0.63.3

//Tabs across the bottom of the screen
  const MainScreenTabNavigator = createBottomTabNavigator(
    {
      HomeStack,
      
      OtherStack,
  
    },
    {
  
      tabBarOptions: {
  
        activeTintColor: 'orange',
        inactiveTintColor: 'black', //white 
        style: {
          backgroundColor: '#ff8278',
          height: global.App_BottomTabBarHeight   // DOESN'T WORK but manually typing  '8%' or 0.08 does
        },
        indicatorStyle: {
          backgroundColor: 'black'
        },
        showLabel: false
      },
      
    }
    
  );

The height wont set with the variable global.App_BottomTabBarHeight = '8%'.

I've also tried doing this: height: Dimensions.get('window').height * global.App_BottomTabBarHeight, where global.App_BottomTabBarHeight = 0.08, but still nothing

If i manually type height: '8%' it works fine.

Sometimes i get this error: JSON value '8%' of type NSstring cannot be converted of a YGValue. Did you forget the % or pt suffix. Is there something about the % causing the problem?

1 Answers

I had the same issue and it was due to a require cycle.

Make sure your global is defined before this file is loaded, otherwise your global.App_BottomTabBarHeight might be "" or undefined.

Related