ListItem crashes unexpectedly on Web
See original GitHub issueI upgraded React Native Elements to v2.3.1 and expo-cli to 3.25.1.
I expected the web application to work with warnings about deprecated props on ListItem but when I start the app in web version an unexpected error occures in ListItem:
ListItem.js:41 Uncaught TypeError: Cannot read property 'grey' of undefined at renderIcon (ListItem.js:41) at ListItem (ListItem.js:220)
Here is an example on Snack to reproduce. https://snack.expo.io/yzVlD7RBS
I don’t know if it helps but debugging it turned out the theme.colors.platform (at line 41 of ListItem) object doesn’t contain any “default” property
These are the lines where I put the breakpoint in the ListItem file and where the error occurs:
const renderIcon = (content, theme) => renderNode(Icon, content, { color: Platform.select(theme.colors.platform).grey, size: 24, });
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:6 (2 by maintainers)
Top GitHub Comments
Really easy fix!
I resolved this locally by adding grey to the theme for platform “default”.
Apparently someone put grey0 instead of grey as platform default. IOS & Android use grey, default uses grey0. See: https://github.com/react-native-elements/react-native-elements/blob/ed6e90d55f18f371ce606019c28f937f816ea3a8/src/list/ListItem.js#L41 And https://github.com/react-native-elements/react-native-elements/blob/62066e442e49630bb8490f5eb9f24412024945a1/src/config/colors.js#L8
Closing the issue. Fixed in #2561 If the issue still persists then feel free to reopen the issue. Happy Hacking 😃