React-native: Error: undefined is not a function (evaluating 'UIManager.setChildren(containerTag,createdTags)')

Created on 5 May 2016  路  18Comments  路  Source: facebook/react-native

Environment:

  • react-native 0.26.0-rc
  • react 15.0.2
  • Android 5.1.1 API 22
  • Mac OSX 10.11.14

Issue:
When running my app (in dev mode), I am getting the following error:

E/ReactNativeJS: undefined is not a function (evaluating 'UIManager.setChildren(containerTag,createdTags)')

All attempts at debugging have failed on my part. The Android app contains both native and react-native code, but I currently have no NativeModules or Views - just an Activity whose onCreate is:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());
        mReactRootView = new ReactRootView(this);
        mReactInstanceManager = ReactInstanceManager.builder()
                .setApplication(getApplication())
                .setBundleAssetName("index.android.bundle")
                .setJSMainModuleName("index.android")
                .addPackage(new MainReactPackage())
                .setUseDeveloperSupport(BuildConfig.DEBUG)
                .setInitialLifecycleState(LifecycleState.RESUMED)
                .build();
        mReactRootView.startReactApplication(mReactInstanceManager, "Insights");
        setContentView(mReactRootView);
    }

I've attached a screenshot of the emulator:

screen shot 2016-05-05 at 12 01 10 pm

Locked

Most helpful comment

Yeah getting this too after upgrading to 0.26.2. I got a temporary workaround by re-adding the deleted code from UIManager.js

if (!UIManager.setChildren) {

  /**
   * Index cache (used by setChildren())
   */
  UIManager._cachedIndexArray = function(size) {
    var cachedResult = this._cachedIndexArray._cache[size];
    if (!cachedResult) {
      var arr = [];
      for (var i = 0; i < size; i++) {
        arr[i] = i;
      }
      this._cachedIndexArray._cache[size] = arr;
      return arr;
    } else {
      return cachedResult;
    }
  };
  UIManager._cachedIndexArray._cache = {};

  /**
   * Fallback setChildren() implementation for Android
   */
  UIManager.setChildren = function(containerTag, createdTags) {
    var indexes = this._cachedIndexArray(createdTags.length);
    UIManager.manageChildren(containerTag, null, null, createdTags, indexes, null);
  };
}

All 18 comments

I see that commit 3a5457cd7cf97171c3435a157f158eefa52bab0a added 'setChildren' to UIManager, but looking at the Java code on my machine, it does not appear that NativeViewHierarchyManager.java in react-native-0.20.1 has this ReactMethod.

@gooftroop yep, that commit is a part of 0.26-rc release.

I upgraded my Android app to RN 0.26 and I started getting this issue. Can anyone please tell me how they addressed it. Thanks

Having the same problem here

@Jonrock23 cleaning and rebuilding in Android Studio helped in my case

I have the same issue. i have cleaned npm cache , closed Packager and build with Android studio but that not resolved my problem.

I am also getting this error, and no amount of clearning or cache-busting is helping resolve.

Same here.

Have the same problem

i resolved the problem by deleting an RN Module ( spinkit). Guys verify your external modules integration

Yeah getting this too after upgrading to 0.26.2. I got a temporary workaround by re-adding the deleted code from UIManager.js

if (!UIManager.setChildren) {

  /**
   * Index cache (used by setChildren())
   */
  UIManager._cachedIndexArray = function(size) {
    var cachedResult = this._cachedIndexArray._cache[size];
    if (!cachedResult) {
      var arr = [];
      for (var i = 0; i < size; i++) {
        arr[i] = i;
      }
      this._cachedIndexArray._cache[size] = arr;
      return arr;
    } else {
      return cachedResult;
    }
  };
  UIManager._cachedIndexArray._cache = {};

  /**
   * Fallback setChildren() implementation for Android
   */
  UIManager.setChildren = function(containerTag, createdTags) {
    var indexes = this._cachedIndexArray(createdTags.length);
    UIManager.manageChildren(containerTag, null, null, createdTags, indexes, null);
  };
}

Yeah, getting this after upgrading to 0.26.1

@tuckerconnelly Thank you! I can develop code again!

I wasted hours trying to figure out why it ran fine on iOS but not Android.

@tuckerconnelly this works for now. Thanks.

Using 0.26.1 and after monkey-patch, it works. Hope that this gets fixed properly.

@tuckerconnelly thanks, that works now

I have the same problem too, when I use "npm init" that default react-native version was "^0.26.1", the react version was "15.0.2",I have this problem.
I resolved the problem by degradation react-native version to "^0.25.1" ,the react version to "0.14.8"

@yangqing0314 thank you! it works!
I hava the same problem too.
react-native version relegated to 0.25.1 == > I change "dependencies": {
"react-native": "^0.25.1"
} and reinstall =>npm install => npm start ==>reload js.

I think react-native version is not stable. When I want to develop with android ,there are many problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DreySkee picture DreySkee  路  3Comments

grabbou picture grabbou  路  3Comments

josev55 picture josev55  路  3Comments

janmonschke picture janmonschke  路  3Comments

jlongster picture jlongster  路  3Comments