undefined is not an object (evaluating '_reactNative.Stylesheet.create')

Viewed 9845

I am getting is pesky error 'undefined is not an object (evaluating '_reactNative.Stylesheet.create')' as can be seen in the screenshot as well.

Following is the code I am using;

import React, {Component} from 'react';
import {Text, Stylesheet} from 'react-native';
import {Content, Container, Body, Title} from 'native-base';
import GoogleStaticMap from 'react-native-google-static-map';

export default class Contact extends Component {
  render() {
    return (
      <GoogleStaticMap
      style={styles.map}
      latitude={'32.064171'}
      longitude={'34.7748068'}
      zoom={13}
      size={{
      width: 300,
      height: 550
    }}
    />);
  }
}

const styles = Stylesheet.create({
  map: {
    width: 300,
    height: 550
  }
});

module.export = Contact;
3 Answers

I was doing ...

import { StyleSheet } from 'react';

But I should do

import { StyleSheet } from 'react-native';

so there is wrong import of stylesheet that you have made from react-native, that is why you are getting that error.

instead you should import as

import {StyleSheet} from 'react-native'

and use it as

const styles = StyleSheet.create({
  map: {
    width: 300,
    height: 550
  }
});

Related