iRoachie / react-native-material-tabs

Material Design implementation of Tabs
MIT License
121 stars 56 forks source link

Default value for getTabWidth #67

Closed JKCooper2 closed 4 years ago

JKCooper2 commented 5 years ago

On Android it seems measure can fire on a ref but sometimes return undefined for the width. Having a default value ensures it doesn't throw a Malformed calls from JS: field sizes are different error in this case

iRoachie commented 5 years ago

Do you actually have an error case or is this just a precaution

codecov[bot] commented 5 years ago

Codecov Report

Merging #67 into next will decrease coverage by 1.28%. The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next      #67      +/-   ##
==========================================
- Coverage   84.61%   83.33%   -1.29%     
==========================================
  Files           6        6              
  Lines          65       66       +1     
  Branches       19       19              
==========================================
  Hits           55       55              
- Misses          6        7       +1     
  Partials        4        4
Impacted Files Coverage Δ
src/components/MaterialTabs.tsx 79.48% <0%> (-2.1%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update cfde9eb...bafdc28. Read the comment docs.

JKCooper2 commented 5 years ago

Without default value: Screen Shot 2019-09-05 at 10 18 13 am

With default value: Screen Shot 2019-09-05 at 10 19 02 am

Reason seems to be width (as well as _ and b) can be undefined. Not sure why, and only happens on android

bar.current.measure((_, b, width) => {
        getTabWidth(width);
      });
JKCooper2 commented 5 years ago

Entire error is: ExceptionsManager.js:86 Invariant Violation: Invariant Violation: [2,10,{"type":"spring","overshootClamping":false,"restDisplacementThreshold":0.001,"restSpeedThreshold":0.001,"stiffness":1171.4,"damping":61,"mass":1,"initialVelocity":0,"toValue":"<>","iterations":1},4269] is not usable as a native method argument

This error is located at: in MaterialTabs (at Tests.js:54)

iRoachie commented 5 years ago

Can I see what code you are using? Just want to make sure we fix the problem correctly

JKCooper2 commented 5 years ago
<MaterialTabs
                    barHeight={40}
                    uppercase
                    items={['Today', 'Week', 'All Forms']}
                    selectedIndex={selectedTab}
                    onChange={onTabPress}
                    barColor={colors.main.cpBlack}
                    indicatorColor={colors.main.cpOrange}
                    textStyle={[getTextStyles({ align: 'center', bold: true, color: colors.main.cpGreyDark }), { paddingBottom: 5 }]}
                    activeTextStyle={[getTextStyles({ align: 'center', bold: true, color: colors.main.white }), { paddingBottom: 5 }]}
                />

I was getting the same error with the default example provided. Only tested on Android simulator

JKCooper2 commented 4 years ago

@iRoachie Can this be merged in? Seems to be affecting on device android as well

CatapultJesse commented 4 years ago

Any update on where this is at?

iRoachie commented 4 years ago

Live in v4.1.2. Thanks for sending