Not work on react-native-web
See original GitHub issueI tried this simple example:
function TestGoogleAutoComplete() {
return (
<>
<GoogleAutoComplete apiKey={GOOGLE_API_KEY}>
{({ handleTextChange, locationResults }) => (
<>
{console.log("locationResults: ", locationResults)}
<View>
<TextInput
placeholder="Search a place"
style={{
height: 40,
width: 300,
borderWidth: 1,
paddingHorizontal: 16,
}}
onChangeText={handleTextChange}
></TextInput>
</View>
</>
)}
</GoogleAutoComplete>
</>
);
}
The console.log is working on expo go (on mobile) But when i try to run on web it shows this error on the console.log:
Access to fetch at 'https://maps.googleapis.com/maps/api/place/autocomplete/json?&input=rua%20&key=***&language=en&types=address' from origin 'http://localhost:19006' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
it should work on web, right? u told on this part of the vídeo that should: https://youtu.be/UFiTL8lAktU?t=209 what should i do?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Issues · necolas/react-native-web - GitHub
Contribute to necolas/react-native-web development by creating an account on GitHub. ... Scroll does not work for TextInput nested in inverted FlatList bug.
Read more >React Native Webview not loading any url ... - Stack Overflow
I am trying to implement react native webview component in my application, but the web view is not loading any url its just...
Read more >Troubleshooting - React Native
These are some common issues you may run into while setting up React Native. If you encounter something that is not listed here,...
Read more >react-native-web - npm
Start using react-native-web in your project by running `npm i ... You'll notice that there is no reference to react-dom in components.
Read more >React Native for Web
You can try React Native for Web from your browser using the official template on CodeSandbox. Fork the template and create your own...
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
@hiwyn I don’t have my pc with me now. But here can you update in your node_module/react-native-google-autocomplete those fetch https://github.com/AppAndFlow/react-native-google-autocomplete/blob/master/lib/services/Google.service.ts#L126 and https://github.com/AppAndFlow/react-native-google-autocomplete/blob/master/lib/services/Google.service.ts#L144
Add
fetch(url, { mode: 'no-cors' });
and see if that fix your problem. If we I will update the lib. I just don’t work with this lib on web.I ask you to do it just because I can’t fix it until tomorrow so if you need that now you can have this fix until.
A lot of people use RN WEB, even more now with expo, so pls at least put on the readme that u do not support rn-web so people don’t waste time