question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot use 'in' operator to search for 'method' in 9

See original GitHub issue

I had this code working in version 5.0.1:

<WebView
    source={require('page.html')}
/>

and in 5.7.0, it crashes on Android (still works on iOS):

Capture d’écran 2019-04-20 à 23 26 58

I’m assuming that it happens because of this line, introduced by the js to ts rewrite (this commit).

It seems the author of this rewrite forgot to handle using require in the source prop.

I’m currently bypassing the problem this way:

<WebView
    source={{uri: Image.resolveAssetSource(require('page.html')).uri}}
/>

This should be fixed though and a test should be added to ensure it doesn’t happen again.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:11

github_iconTop GitHub Comments

11reactions
vmarquetcommented, Apr 29, 2019

@Titozzz Because the documentation cannot change?

Capture d’écran 2019-04-29 à 14 06 06

Do you really expect people to read the entire documentation and notice the api changes at every update? No, that’s why you should not drop features silently, that’s why properly managed projects have a changelog file, but there is none in this repository.

11reactions
Titozzzcommented, Apr 22, 2019

@vmarquet Docs never specified you syntax should have worked which is why you encountered that issue. See (docs)[https://github.com/react-native-community/react-native-webview/blob/master/docs/Reference.md#source].

Regarding

This should be fixed though and a test should be added to ensure it doesn’t happen again.

If you think changes need to be done in a repository, please submit a pull request, since you already spent time to track the bug, it’s even more enjoyable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: cannot use 'in' operator to search for 'x' in 'y'
The JavaScript exception "right-hand side of 'in' should be an object" occurs when the in operator was used to search in strings, ...
Read more >
Uncaught TypeError: Cannot use 'in' operator to search for ...
The in operator only works on objects. You are using it on a string. Make sure your value is an object before you...
Read more >
JavaScript TypeError - Cannot use 'in' operator to search for 'X ...
This JavaScript exception Cannot use 'in' operator to search for 'X' in 'Y' occurs if in operator is used to search in strings,...
Read more >
TypeError: cannot use 'in' operator to search for 'x' in 'y'
The in operator can only be used to check if a property is in an object. You can't search in strings, or in...
Read more >
Uncaught TypeError Cannot use in operator to search for 324 in
This is my code that sends a Get request to php file by ajax. When I use $.each method, it get the error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found