React-native: has no propType for native prop of native type `number`

Created on 26 Oct 2015  路  6Comments  路  Source: facebook/react-native

I try to bridge GLSurfaceView to React Native on Android.
This is ViewManager subclass
GLSurfaceViewManager.java

package com.oney.kk;

import android.os.SystemClock;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.opengl.GLSurfaceView;

import com.facebook.csslayout.CSSNode;
import com.facebook.csslayout.MeasureOutput;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.uimanager.*;
import android.util.Log;

public class GLSurfaceViewManager extends SimpleViewManager<GLSurfaceView> {
  private final static String TAG = GLSurfaceViewManager.class.getCanonicalName();
  public static final String REACT_CLASS = "GLSurfaceView";

  @Override
  public String getName() {
    return REACT_CLASS;
  }

  @UIProp(UIProp.Type.NUMBER)
  public static final String PROP_SRC = "src";

  @Override
  public GLSurfaceView createViewInstance(ThemedReactContext context) {
    Log.d(TAG, "create!"); // Never call
    GLSurfaceView view = new GLSurfaceView(context);
    return view;
  }
  @Override
  public void updateView(final GLSurfaceView view, final CatalystStylesDiffMap props) {
    super.updateView(view, props);

    if (props.hasKey(PROP_SRC)) {
      // do something...
    }
  }
}

GLSurfaceView.js

'use strict';
var React = require('react-native');
var { requireNativeComponent } = React;

var theView = {
  name: 'GLSurfaceView',
  propTypes: {
    src: React.PropTypes.number,
  },
};

var GLSurfaceView = requireNativeComponent('GLSurfaceView', theView);

module.exports = GLSurfaceView;

And I get "GLSurfaceView" has no propType for native prop "GLSurfaceView.scaleX" of native type number
image

Locked

Most helpful comment

image

All 6 comments

you prop has name "src"(PROP_SRC = "src"), but on screenshot you call prop with name "scaleX"

I never call prop name "scaleX".
Even I just require it and don't render it in any place, it still shows the error.

var GLSurfaceView = require('./GLSurfaceView');

oh, sorry, my mistake
I think you should extends from ViewManager, not from SimpleViewManager, which has many props pre-defined, such as scaleX

Thanks, your suggestion solves the problem. But I find another solution.

var theView = {
  name: 'GLSurfaceView',
  propTypes: {
    src: React.PropTypes.number,
  },
};

var GLSurfaceView = requireNativeComponent('GLSurfaceView', theView, {nativeOnly: {
  'scaleX': true,
  'scaleY': true,
  'testID': true,
  'decomposedMatrix': true,
  'backgroundColor': true,
  'accessibilityComponentType': true,
  'renderToHardwareTextureAndroid': true,
  'translateY': true,
  'translateX': true,
  'accessibilityLabel': true,
  'accessibilityLiveRegion': true,
  'importantForAccessibility': true,
  'rotation': true,
  'opacity': true,
}});

module.exports = GLSurfaceView;

i get error: 'Image' has no propType for native prop 'RCTImageView.overlayColor' of native type 'number' 锛宧ow can i resolve it.

image

Was this page helpful?
0 / 5 - 0 ratings