Crashing when using style prop that is a string
See original GitHub issueHere is the crashing error:
ESLint: 7.20.0
TypeError: Cannot read property 'type' of undefined
Occurred while linting /myuser/myapp/src/screens/Walkthrough.tsx:82
at JSXAttribute (/myuser/myapp/node_modules/eslint-plugin-react-native/lib/rules/no-single-element-style-arrays.js:40:35)
at /myuser/myapp/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/myuser/myapp/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/myuser/myapp/node_modules/eslint/lib/linter/node-event-generator.js:256:26)
at NodeEventGenerator.applySelectors (/myuser/myapp/node_modules/eslint/lib/linter/node-event-generator.js:285:22)
at NodeEventGenerator.enterNode (/myuser/myapp/node_modules/eslint/lib/linter/node-event-generator.js:299:14)
at CodePathAnalyzer.enterNode (/myuser/myapp/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
at /myuser/myapp/node_modules/eslint/lib/linter/linter.js:954:32
at Array.forEach (<anonymous>)
This is caused because the StatusBar component from Expo has a style prop that can be auto
, inverted
, light
, or dark
. Here is the snippet where is crashing:
<StatusBar style="light" backgroundColor={COLORS.PRIMARY[500]} animated />
This, is not:
<StatusBar style={"light"} backgroundColor={COLORS.PRIMARY[500]} animated />
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:7 (2 by maintainers)
Top Results From Across the Web
App crash in release mode when using 'View.propTypes.style'
View.propTypes.style isn't valid and printed a deprecation message for several releases before it was removed. Use ViewPropTypes.style instead.
Read more >Material UI Select component crashing React application
Made sure value prop is an empty string, with a child matching MenuItem (no luck); Set a defaultValue prop (no luck); Removing other...
Read more >8 Practices In React That Will Crash Your App In The Future
If it is a string, then the caller passed in the videoType so we can skip first step. Someone has found that the...
Read more >UILabel Crash with Attributed Text | Apple Developer Forums
In Xcode version 10.0 and swift 4.2 my app crashes when setting the content of UILabel.attributedText and accessing any of UILabels variables. For...
Read more >Handling common HTML and CSS problems - MDN Web Docs
Unrecognized HTML elements are treated by the browser as anonymous inline elements (effectively inline elements with no semantic value, similar ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@AlanSl, just made a release, hope it works! If it breaks let me know.
As a temporary workaround you could assign the style string to a variable:
and then use that as your style:
This will prevent
eslint
from crashing. Then ofc you will get thereact/style-prop-object
rule error, but you can fix this by addingStatusBar
as an exception in your rules.