-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
当使用react-native-scrollable-tab-view组件时
报错 Cannot read property 'style' of undefined
去掉所有组件后报错 Cannot read property 'addEventListener of undefined'
然后展示下使用这个组件的代码 大家帮忙找找错
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>
);
}
}
Activity
trops commentedon May 15, 2017
Yeah I am getting something similar using Router,
undefined is not an object(evaluating ViewPropStyles.style
twelvearrays commentedon May 15, 2017
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 commentedon 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 commentedon May 16, 2017
Forgot about index.js!
pplgin commentedon May 16, 2017
@holleword you can install it @0.7.4 or update your react-native@^0.45
springHyc commentedon May 19, 2017
@pplgin 我引用了@0.7.4版本,style还是undefined。
jp928 commentedon May 19, 2017
@springHyc
升级react native版本到0.45
springHyc commentedon May 19, 2017
@jp928 我已经把react-native-scrollable-tab-view升级到0.7.4了,还需要升级react native版本到0.45才可以?
springHyc commentedon May 19, 2017
不用做任何版本的升级,是库中的代码(index.js)文件中作者少些了style属性。
请参考下面的链接。springHyc@f154460
style
of undefined GeekyAnts/NativeBase#846zhao33055 commentedon Jun 14, 2017
@springHyc ,It's does't work.
zhao33055 commentedon Jun 14, 2017
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 commentedon Aug 16, 2017
my version is 0.43.4.i used @0.7.4
worked
exos commentedon 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:
Akatsukishen commentedon Jun 21, 2018
it works for me while react-native version is 0.40.0.