mithelan
mithelan

Reputation: 190

ReferenceError: Expo is not defined-React-Native

i'm new to react-native. I tried to use EXPO in my code. but it is saying as ReferenceError: Expo is not defined-React-Native

 class Main extends Component {
  
  render() {
 
    return (
      <View style={{flex:1, paddingTop: Platform.OS === 'ios' ? 0 : Expo.Constants.statusBarHeight }}>
     
     </View>
    );
  }
}

Upvotes: 1

Views: 1859

Answers (2)

Nacho Zullo
Nacho Zullo

Reputation: 571

Like Bas van der Linden says you need to import Constants.

import { Constants } from 'expo';

But also you need to import Platform from react-native

import { Platform } from 'react-native';

Upvotes: 1

bas
bas

Reputation: 15722

Install expo constants like this expo install expo-constants.

import Constants from 'expo-constants';

class Main extends Component {
  render() {
    return (
      <View
        style={{
          flex: 1,
          paddingTop: Platform.OS === 'ios' ? 0 : Constants.statusBarHeight,
        }}
      />
    );
  }
}

Source: https://docs.expo.io/versions/latest/sdk/constants/

Upvotes: 2

Related Questions