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

Created on 18 May 2017  ·  29Comments  ·  Source: facebook/react-native

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
Locked

Most helpful comment

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-*

All 29 comments

Facing the same issue, how did you end up solving it. Stuck with it for quite some time now.

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

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.

@kevineaton same problem with me did u found any solution?

@77ukhtar Check out https://github.com/react-community/react-navigation/issues/1352 , seems to have a (temporary) workaround from @chenyi5266 . The fixes haven't been merged yet into master ( https://github.com/react-native-training/react-native-elements/pull/384 )

I personally have not seen this on Windows w/building for Android (latest Android Studio & updates) but I have seen this on Mac for iOS (latest updates)

@virgil9306 thanks, i will just not use nativebase on this project till it fixed

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

still no solution to this? I am desperate about finding about this bug :/

@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

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

Hi @kevineaton @77ukhtar I updated native-base from 2.1.2 to 2.1.4 and react-native from 0.43.4 to 0.44.0. But then I'm getting an error: DeviceInfo native module is not installed correctly...Help please? Thanks

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-*

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

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

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

Greetings
I follow this upgrading page
https://facebook.github.io/react-native/docs/upgrading.html

and it's working fine

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

@shadman264 Thanks for the tip, you're a life saver 👍
worked for me after I specified the version in the package.json for the dependencies I didn't wan't to update (and created this mess in the first place when they got updated :'( )

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

guys i'm having the same problem and i can't upgrade since i have other dependencies .. so what should i do ? thanks
screen shot 2017-07-02 at 21 12 32

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

So i had the same problem. it's quite newbie problem in fact.
react-native link doesn't work.
for ios you have to manually link the xcodeproj thing to your project.(not sure about the android version yet)
here's a good tutorial for getting over this problem.
https://blog.nativebase.io/adding-third-party-native-modules-using-react-native-cbcb9e3786ba
it had little to do with version and other bs...

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 am a newer for RN. This problem has bothered me a few days.

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

I only had to update RN from 0.43.4 to 0.44.0.
Many thanks to @77ukhtar, @shadman264.

i have the same issue somebody knows how to solve?

@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

Was this page helpful?
0 / 5 - 0 ratings