Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'LikeView' has no propType 'RCTFBLikeView.onLayout' of native type 'boolean' if you haven't changed this

LikeView has no propType for native prop RCTFBLikeView.onLayout of native type boolean If you haven't changed this prop yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away. enter image description here

Not sure why I am getting this error. I'm not using LikeView at all in the android app. I've tried running npm start --reset-cache.

Also iOS version of the app runs no problem. This only occurs for android.

Any suggestions welcomed.

Thanks!

like image 514
xclearner Avatar asked May 23 '17 23:05

xclearner


People also ask

What is Javascript Proptype?

PropTypes are simply a mechanism that ensures that the passed value is of the correct datatype. This makes sure that we don't receive an error at the very end of our app by the console which might not be easy to deal with.

How do you use PropTypes in a functional component React?

import React from 'react'; import PropTypes from 'prop-types'; function List(props) { const todos = props. todos. map((todo, index) => (<li key={index}>{todo}</li>)); return (<ul></ul>); } List. PropTypes = { todos: PropTypes.

What is PropTypes node?

PropTypes. node: any render-able value like numbers and string, that can actually be rendered on screen. PropTypes. any: any type of value, even those are non-render-able like boolean.


2 Answers

I figured out that the problem is (as RN points out) a mismatch between the native props and the JS ones on the props that every view uses. Namely:

  • renderToHardwareTextureAndroid
  • onLayout
  • accessibilityLiveRegion
  • accessibilityComponentType
  • importantForAccessibility
  • accessibilityLabel
  • testID

Since I am not using any of the views that the package uses, namely:

  • FBLikeView
  • FBLoginButton
  • FBSendButton
  • FBShareButton

I tried to set this props as 'native only', so that they are not bound to the JavaScript side. In every component (in the example, FBShareButton.js), I replaced:

const RCTFBShareButton = requireNativeComponent(
    'RCTFBShareButton',
    ShareButton,
);

with

const RCTFBShareButton = requireNativeComponent(
  'RCTFBShareButton',
  ShareButton,
  {
    nativeOnly: {
      onChange: true,
      onLayout: true,
      testID: true,
      importantForAccessibility: true,
      accessibilityLiveRegion: true,
      accessibilityComponentType: true,
      accessibilityLabel: true,
      renderToHardwareTextureAndroid: true,
    }
  },
);

I am now going to check if the views are getting rendered properly and edit my post later, but if you just want to be able to compile your app in order to continue development (as it is my case at the moment), that should let you do so.

Edit

I successfully rendered the LoginButton component using the example in the README with my changes.

Edit 2

I made a pull request with my changes to the package. I don't like the solution, but it might raise FB's attention. In the meantime, you can just use my fork. In your package.json, just replace the fbsdk line with this:

"react-native-fbsdk": "git+https://github.com/motius/react-native-fbsdk.git#fix-views"

This other pull request might be a better solution, actually.

like image 197
martinarroyo Avatar answered Sep 25 '22 02:09

martinarroyo


Similar to the solution suggested by @martinarroyo, I figured that it has to do with some components that are not synced between the native code and the js code. If you are not using these components, instead of adding the nativeOnly property in every js file you use it, I commented out the exports from the react-native-fbsdk index.js as follows:

//native components
// exports.LikeView = require('./FBLikeView');
// exports.LoginButton = require('./FBLoginButton');
// exports.SendButton = require('./FBSendButton');
// exports.ShareButton = require('./FBShareButton');

Obviously this is just a workaround but that should get you through that error

like image 25
Muzikant Avatar answered Sep 26 '22 02:09

Muzikant