react-native: undefined is not an object(evaluating 'ViewPropTypes.style')

Description

When i clone a project from git, after ‘npm install’ react-native run-ios,the error coming.But others in team can run success.

Reproduction Steps and Sample Code

Additional Information

react-native-cli: 2.0.1
react-native: 0.42.3

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 30

Most upvoted comments

Sorry, this is not related to React Native. The problem was with a version of @expo/ex-navigation. Link to the issue.

我只是拉一个分支,开发新项目,分支是没问题,要怎么解决

Update React-Native to 0.44.0 in package.json Then run the following commands:

  1. sudo rm -rf node_modules && npm install
  2. sudo rm -fr $TMPDIR/react-*

for those that have same issue after install this package try this.

in file node_modules/react-native-maps/lib/components/MapView.js

in line 63

replace : style: ViewPropTypes.style for : style: PropTypes.style

it fix my issue 😃

I’m getting this problem but on react-native 0.42.3. I don’t have the option of upgrading react-native because then a bunch of other libraries break due to the react peer dependency upgrade. Hoping for other ideas

@kevineaton I solved the error by updating native-base from 2.1.2 to 2.1.4 and react-native from 0.43.4 to 0.44.0

I have this issue and I do not use expo nor do I see any expo dependencies. I am using Native Base and a few other libraries. Everything was running fine and then I tried to update a library and now I get this error. I reverted and even did a full git checkout of the repo before the attempted upgrade and now I get this anytime I try to run the application.

@gitarre94 depends on your RN version.

~ >0.45 you must use ViewPropStyles.style - even in third party packages. You’ll have to go through and upgrade or fork to remove all references to View.propTypes.style ~ <0.45 you can use View.propTypes.style but you might not have access to ViewPropStyles.style

for those who are still unable to figure out, try following

import ViewPropTypes from ‘react-native’

and then replace View.propTypes with ViewPropTypes

I have had the same problem If you use a third-party component, change ViewPropTypes.style to View.propTypes.style

Yes! @shadman264 your solution works! Thanks!!!

@77ukhtar you are the true hero here! works for me!

having the same problem after pulling project from git with android on both Windows & ubuntu 14.04. Can anyone provide any working solution?

I was having the same issue. So I updated the RN and change from import React, { Component, PropTypes } from 'react' to import React, { Component } from 'react' import PropTypes from 'prop-types';

Same as suark, I’m using react-native-maps. Can’t upgrade.

Okay @shadman264. Let me try this real quick. Thanks