Cannot read property 'style' of undefined
See original GitHub issueI get this error when I run my tests with jest and it tries to import react-native-snap-carousel :
TypeError: Cannot read property 'style' of undefined at Object.<anonymous> (node_modules/react-native-snap-carousel/index.js:472:842)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:8
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Cannot read property 'style' of undefined -- Uncaught Type Error
1. This works when I try it here: jsfiddle.net/du2ot93e - I think your if statement is failing. · Do you reach the if...
Read more >How To Fix Cannot Read Property 'style' of Null in JavaScript
This error boils down to one problem. The element you are trying to access does not exist in the DOM (document object model)...
Read more >Cannot read property 'style' of undefined" browser console error
Symptoms. Form is in a broken state (example - right click menu options, related lists, reference fields etc are unavailable) as a result...
Read more >Cannot read property 'style' of undefined · Issue #779 - GitHub
Works fine on android device. TypeError: Cannot read property 'style' of undefined. Module.../../../react-native-snap- ...
Read more >Cannot read property 'style' of undefined on Details Row
Cannot read property 'style' of undefined on Details Row ... I have a details row with datatables. Details row is working properly, but...
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 FreeTop 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
Top GitHub Comments
hi guys,
ran into this problem as well.
i think the problem is related to these three lines https://github.com/archriss/react-native-snap-carousel/blob/master/index.js#L56 https://github.com/archriss/react-native-snap-carousel/blob/master/index.js#L60 https://github.com/archriss/react-native-snap-carousel/blob/master/index.js#L87
if I temporarily comment those lines out in
node_modules/react-native-snap-carousel
then jest test no longer gets the described error.these three lines appear to point to this line in
react-native
source -> https://github.com/facebook/react-native/blob/v0.43.1/Libraries/Components/ScrollView/ScrollView.js#L297a temporary solution is to create a mock
react-native-snap-carousel.js
inside a__mocks__
folder. mine just looks like:I recently had a similar issue while running some tests
Since I need to make assertions on each carousel item, I implemented this simple mock: