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

Cannot read property 'style' of undefined #634

Closed
holleword opened this issue May 15, 2017 · 14 comments
Closed

Cannot read property 'style' of undefined #634

holleword opened this issue May 15, 2017 · 14 comments

Comments

@holleword
Copy link

holleword commented May 15, 2017

当使用react-native-scrollable-tab-view组件时
报错 Cannot read property 'style' of undefined
Uploading Screenshot_2017-05-16-00-12-38-451_com.transport.png…

去掉所有组件后报错 Cannot read property 'addEventListener of undefined'
Uploading Screenshot_2017-05-16-00-14-25-880_com.transport.png…

然后展示下使用这个组件的代码 大家帮忙找找错

import React, { Component } from 'react';
import {
ScrollView,
ListView,
} from 'react-native';
import AcceptTask from './acceptTask';
import TaskSure from './taskSure';

import ScrollableTabView,{DefaultTabBar} from 'react-native-scrollable-tab-view';

export default class myTask extends React.Component{

render(){
return(

<ScrollableTabView
    style={{marginTop:50,paddingBottom:50}}
    renderTabBar={() => <DefaultTabBar/>}
    tabBarUnderlineStyle={{backgroundColor:'#DE0A17',height:2}}
    tabBarBackgroundColor='#FFFFFF'
    tabBarActiveTextColor='#DE0A17'
    tabBarInactiveTextColor='#666'
    scrollWithoutAnimation={true}
    tabBarTextStyle={{fontSize: 18}}
>
  <ScrollView tabLabel='可接任务' style={{flex:1,backgroundColor:'#e4e4e4'}}>
    <AcceptTask/>
  </ScrollView>
  <ScrollView tabLabel='确认任务' style={{flex:1,backgroundColor:'#e4e4e4'}}>
    <TaskSure/>
  </ScrollView>
</ScrollableTabView>
);

}
}

@trops
Copy link

trops commented May 15, 2017

Yeah I am getting something similar using Router,

undefined is not an object(evaluating ViewPropStyles.style

@twelvearrays
Copy link

Commenting out all of the ViewPropTypes.style in the propTypes object in ScrollableTabBar.js and DefaultTabBar.js in the react-native-scorllable-tab-view fixes this error.

@trops
Copy link

trops commented May 15, 2017

Ahh excellent! I also had to comment it out in the index.js file, but all good, it compiled! Thank you :-)

@twelvearrays
Copy link

Forgot about index.js!

@pplgin
Copy link

pplgin commented May 16, 2017

@holleword you can install it @0.7.4 or update your react-native@^0.45

@springHyc
Copy link

@pplgin 我引用了@0.7.4版本,style还是undefined。

@jp928
Copy link

jp928 commented May 19, 2017

@springHyc

升级react native版本到0.45

@springHyc
Copy link

@jp928 我已经把react-native-scrollable-tab-view升级到0.7.4了,还需要升级react native版本到0.45才可以?

@springHyc
Copy link

不用做任何版本的升级,是库中的代码(index.js)文件中作者少些了style属性。
请参考下面的链接。springHyc@f154460

@hetchzhao
Copy link

@springHyc ,It's does't work.

@hetchzhao
Copy link

I found the version of react-native in demo is 0.44 and it's ok.But mine does't work,my version is 0.43.3.

@laclys
Copy link

laclys commented Aug 16, 2017

my version is 0.43.4.i used @0.7.4
worked

@exos
Copy link

exos commented Sep 23, 2017

It's a problem with >=0.6.6 and react-native >=0.44.0, If you uses react-native below 0.44.0 you need to force to use 0.7.4:

$ npm install react-native-scrollable-tab-view@0.7.4

@Akatsukishen
Copy link

it works for me while react-native version is 0.40.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests