Ui: cannot read property 'shape' of undefined

Created on 6 Nov 2017  路  4Comments  路  Source: shoutem/ui

Following is my App.js

import React, { Component } from 'react';
import { Examples } from '@shoutem/ui';

export default class App extends Component {
  render() {
    return (
        <Examples />
    );
  }
}

Package.json

    "@shoutem/ui": "^0.21.3",
    "react": "16.0.0",
    "react-native": "0.50.1"

Error:
cannot read property 'shape' of undefined on iphone X,
undefined is not an object (evaluating '_react.PropTypes.shape') on iphone 7

Most helpful comment

I work around it by patching React 16 (for the time being until the guys from shoutem would fix this)

Steps:

  1. npm/yarn install prop-types create-react-class
  2. Add the follwing snippet to the end of your app's node_modules/react/index.js
module.exports.PropTypes = require('prop-types');
let createClass;
Object.defineProperty(module.exports, 'createClass', {
  get: function() {
    if (!createClass) {
      createClass = require('create-react-class').bind(module.exports);
    }
    return createClass;
  }
});

Notice this patch is only valid for your local environment and everyone who clones the project and/or does 'yarn/npm install' would have to apply the patch (step 2).

All 4 comments

I am getting the error as " undefined is not an object (evaluating '_react.PropTypes.shape) "

Just in case somebody else gets into this same issue, you could use my fork as a temporary fix:
yarn add "github:diegocouto/ui.git"

The PR #314 might fix most of the errors, but a lot of other libs also had to be updated in order to be able to use this package with React v16.0.0.

I work around it by patching React 16 (for the time being until the guys from shoutem would fix this)

Steps:

  1. npm/yarn install prop-types create-react-class
  2. Add the follwing snippet to the end of your app's node_modules/react/index.js
module.exports.PropTypes = require('prop-types');
let createClass;
Object.defineProperty(module.exports, 'createClass', {
  get: function() {
    if (!createClass) {
      createClass = require('create-react-class').bind(module.exports);
    }
    return createClass;
  }
});

Notice this patch is only valid for your local environment and everyone who clones the project and/or does 'yarn/npm install' would have to apply the patch (step 2).

Hey guys,

We've since fixed these issues with version 0.22.0 of the UI toolkit. Closing issue as resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  8Comments

haikov picture haikov  路  4Comments

alejandronanez picture alejandronanez  路  9Comments

acornejo picture acornejo  路  3Comments

mypark picture mypark  路  8Comments