0

I have started learning react-native and When i am following different tutorials on net, some are using Ecma6 and other are without it. Most of the places I have read that we have a choice to use either of the syntax. But when I try to create app without ECMA6 it always gives me this error

undefined is not a function evaluating react create class

This is my code :

'use strict';

var React = require('react-native');

var {
  AppRegistry,
  StyleSheet,
  Text,
  TextInput,
  View,
  Image,
  ListView
} = React;

var MyApp = React.createClass({

......

});

AppRegistry.registerComponent('MyApp', () => MyApp);

Am I missing something or is it not possible to use code without ECMA6 in new version of react native I am using version 0.27

2

1 Answer 1

2

importing React from react and other component from react-native fixed the issue

import React from 'react';

import {
  AppRegistry,
  StyleSheet,
  Text,
  TextInput,
  View,
  Image,
  ListView
} from 'react-native';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.