mjpablo23
mjpablo23

Reputation: 731

React Native error: undefined is not a function

I am starting to learn React Native. I am following a tutorial and have written the following code:

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

var {
  Text,
  View,
  AppRegistry
} = React;

var StopWatch = React.createClass({
  render: function() {

  }
});

AppRegistry.registerComponent('stopwatch', function() {
  return StopWatch;
});

However, I am getting this error:

undefined is not a function (evaluating 'React.createClass({displayName:'StopWatch', 
render:function render() {}
})')

I run React Native in the Android simulator, using the command

react-native run-android

The file is

App.js

Upvotes: 0

Views: 324

Answers (1)

Max Millington
Max Millington

Reputation: 4498

This doesn't really answer your question, but why do it this way using deprecated syntax?

Try the facebook react-native tutorial here: https://facebook.github.io/react-native/docs/tutorial.html

Or better yet, use the wonderful create-react-native-app

This should get you up and running

Upvotes: 4

Related Questions