Nativebase: Provide null or undefined children? (Cannot read property 'type' of null)

Created on 2 Nov 2016  路  5Comments  路  Source: GeekyAnts/NativeBase

https://github.com/GeekyAnts/NativeBase/blob/master/Components/Widgets/ListItem.js#L181

It seems like the widgets do no support null or undefined children, how can I bypass this error/bug?

<List dataArray={notifications} renderRow={(item) => <ListItem> { item.avatar && <Thumbnail size={30} source={item.avatar} /> } // Error Here <Text>{`${item.message}`}</Text> </ListItem> } />

bug

All 5 comments

We will fix this in the next version. Until then you can use this workaround

<ListItem>
  { item.avatar ? <Thumbnail size={30} source={item.avatar} /> : <Text /> }
  <Text>{`${item.message}`}</Text>
</ListItem>

Fixed in v0.5.13

I think I have similar issue, event I updated to 0.5.13:
Cannot read property 'type' of null

on:

         <View>
            <FontAwesomeIcon name="circle" style={iconStyles} /> // here
            <Text>{alert.message}</Text>
          </View>

File CardItem.js Line: 114:

imagePresent() {
        var imagePresent = false;
        React.Children.forEach(this.props.children, function (child) {
            if(child.type == Image) // <---- here
                imagePresent = true;
        })

        return imagePresent;
    }

cc @himanshu-satija

same issue in button

        React.Children.map(this.props.children, child => child.type === Text ? React.cloneElement(child, { capitalize: true, ...child.props }) : child);

should be

        React.Children.map(this.props.children, child && child => child.type === Text ? React.cloneElement(child, { capitalize: true, ...child.props }) : child);

+1 have the same issue with Button and an empty Text tag gives another error on Android when it tries to capitalize the text. Using an empty View tag as a workaround for now until fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aloifolia picture aloifolia  路  3Comments

muthuraman007 picture muthuraman007  路  3Comments

maphongba008 picture maphongba008  路  3Comments

kitsune7 picture kitsune7  路  3Comments

bsiddiqui picture bsiddiqui  路  3Comments