Skip to content

Cannot read property 'style' of undefined #634

@holleword

Description

@holleword

当使用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>
);

}
}

Activity

trops

trops commented on May 15, 2017

@trops

Yeah I am getting something similar using Router,

undefined is not an object(evaluating ViewPropStyles.style

twelvearrays

twelvearrays commented on May 15, 2017

@twelvearrays

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

trops commented on May 15, 2017

@trops

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

twelvearrays

twelvearrays commented on May 16, 2017

@twelvearrays

Forgot about index.js!

pplgin

pplgin commented on May 16, 2017

@pplgin

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

springHyc

springHyc commented on May 19, 2017

@springHyc

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

jp928

jp928 commented on May 19, 2017

@jp928

@springHyc

升级react native版本到0.45

springHyc

springHyc commented on May 19, 2017

@springHyc

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

springHyc

springHyc commented on May 19, 2017

@springHyc

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

zhao33055

zhao33055 commented on Jun 14, 2017

@zhao33055

@springHyc ,It's does't work.

zhao33055

zhao33055 commented on Jun 14, 2017

@zhao33055

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

laclys commented on Aug 16, 2017

@laclys

my version is 0.43.4.i used @0.7.4
worked

exos

exos commented on Sep 23, 2017

@exos

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

Akatsukishen commented on Jun 21, 2018

@Akatsukishen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jp928@ptomasroos@exos@trops@zhao33055

        Issue actions

          Cannot read property 'style' of undefined · Issue #634 · ptomasroos/react-native-scrollable-tab-view