Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

has no propType for native prop of native type number #3685

Closed
oney opened this issue Oct 26, 2015 · 6 comments
Closed

has no propType for native prop of native type number #3685

oney opened this issue Oct 26, 2015 · 6 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@oney
Copy link

oney commented Oct 26, 2015

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

@nucleartux
Copy link
Contributor

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

@oney
Copy link
Author

oney commented Oct 26, 2015

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');

@nucleartux
Copy link
Contributor

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

@oney
Copy link
Author

oney commented Oct 26, 2015

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;

@oney oney closed this as completed Oct 26, 2015
@youxikaifa
Copy link

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

@youxikaifa
Copy link

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants