React-native: [0.26.1] _reactNative2.default.createElement is not a function

Created on 24 May 2016  路  9Comments  路  Source: facebook/react-native

I also can't run the project.

I'm getting this red screen error on start:

_reactNative2.default.createElement is not a function

This is weird because it's happening in the render method of index.ios.js which looks like this:

class TheApp extends Component {
  render() {
    return (
        <Provider store={store}>
            <TheAppComponent /> // Red Screen points right here
        </Provider>
    );
  }
}

TheAppComponent is exported like so: export default connect((state) => (state))(WhasomeMobile);

I've gone through and updated my project to include Component and PropTypes from React and even went through all of the third party dependencies that haven't done so yet. I've also done react-native upgrade and rnpm upgrade and nothing helps.

The string _reactNative2.default.createElement doesn't even exist anywhere in my project.

I've spent a day and a half on this already. Any ideas?

Locked

Most helpful comment

You probably need to fix your imports:

import React from 'react';
import ReactNative from 'react-native';

This is so you run React.createElement instead of ReactNative.createElement, which doesn't exist.

All 9 comments

You probably need to fix your imports:

import React from 'react';
import ReactNative from 'react-native';

This is so you run React.createElement instead of ReactNative.createElement, which doesn't exist.

@seanfuture Please don't say such things.

We've listed this in the release notes and also listed a codemod which you can use to migrate your project automatically - https://github.com/facebook/react-native/releases/tag/v0.25.1

We've valid reasons for doing so and have no intention to break anyone's code. But React Native is a moving target and breakage is unavoidable.

Fair enough - Just pointing out how incredibly impactful this breaking change was .. Please be more careful regarding the core product.

The awesome thing would be to have a bit more specific warning maybe ?

I had a really weird error talking about Babel or something when I forgot to update some of my components

If u wanna upgrade you should read the release notes, there is all the breaking changes that u need to take in consideration.

The breaking changes are necessary to move faster

@adrienthiery We had the warning in 0.25. It was removed completely in 0.26. But maybe we should have kept the warning for 2-3 releases before removing it completely.

Such is the nature of working with anything under heavy and active development. It'll be good for us all in the long run. Better now than much further down the line.

I submitted a PR which will show a better error message. Hope it helps.

my project is web-react use webpack package get a error createElement is not a function , i dont konw how to do it.

Was this page helpful?
0 / 5 - 0 ratings