Can't make Mutation to work using react-apollo-hooks with React Native project - react-native

I have a React Native project and I would like to make Apollo GraphQL work. I tried everything, I refer the issue I am having which I did the submission here: TypeError: Cannot read property 'data' of undefined at MutationData.onMutationCompleted (react-hooks.cjs.js:654)
Am I doing something wrong in configuration or usage?
Any suggestion would be very helpful.
Thank you,
Andrea

Related

Something I can use with React Native for web

I like React Native's some features like Flatlist, Modal, Animation. I wanted to develop for web with React Native or Expo. I use react navigation but have 404 errors in refresh pages. I also want When user put www.mywebsite.com/post/postid, it will go directly into postid's page. I tried react-router-dom with HashBrowser. Not great! I kind of want something better than hash browser. What can I use? Any advice please.
I use also react-native-web and react-navigation. If you want the react-navigation to work with the links correct, you must set up the config object like the documentantion
If you don't set up correctly the config object, react-navigation doesn't throw errors in your console, but it doesn't work right!
The question was before 3 months, but I hope this answer helps someone, with the same problem!

REACT NATIVE - Expo AV didJustFinish

I'm currently working on an application in React Native. I need to be able to read and manage audios for my project.
I find the documentation for Expo AV rather badly done, there is a lack of examples of use.
To make it simple, I want to get the didJustFinish value (boolean). To do so, I created a loop using setOnPlaybackStatusUpdate but I don't understand how to get the didJustFinish value back afterwards.
Okay, I found the solution.
Here's an example:
yourSoundObject.setOnPlaybackStatusUpdate((playbackStatus) => {
console.log(playbackStatus.didJustFinish)
console.log(playbackStatus.positionMillis)
})
playbackStatus is a property that is only added in the function called by setOnPlaybackStatusUpdate.
For ease of use I've done this in an anonymous function

How to resolve Undefined is not an object (evaluating 'RCTToastAndroid.TOAST')

I want to run a react-native app. Before, it runs normally. An then when I add a sound and I run it again it show Undefined is not an object (evaluating 'RCTToastAndroid.SHORT')
I already open another stackoverflow question like this but it not resolve my problem
Looking at the error, even without any code from you, I have some assumptions.
You are probably trying to implement Android Toast in your app.
In the react-native docs there is an example of how to do it here and you are getting an error because of it.
Please Provide the full code where you are implementing it so we can get an proper solution.
By what you posted in your answer, there is some error in implementing Android's Toast.
OR
You have the Toast module implemented correctly, but your are in an IOS device and in you can't use Android's Toast in IOS.
If this is your case, you can try implementing something different to display and use react native Plataform.select to render the Toast in Android and something else in IOS.

react-native-navigation with context api (react 16.3)

has anybody being able to use the new Context API introduce in react 16.3 with react-native-navigation?
I'm having trouble trying to set it up as with react-native-navigation there is no main component where i can manage a state and then render the Context.Provider components, just the Navigation.startSingleScreenApp or similar functions.
Tks in advance for any help you can provide
Environment
React Native Navigation version: 1.1.403
React Native version: 0.55.4
Platform(s): iOS
Device info : Simulator
Please update your question with the simplest code example that shows your problem.
Generally, you can wrap your for example outside or inside whatever is your .
Maybe see this guide https://medium.com/#505aaron/a-practical-react-native-problem-solved-with-the-context-api-eecaf2e05202 for a simple enough example that does create a custom Context Provider/Consumer pair that also has its own state.
react-native-navigation with Context API is not possible. there are some workarounds (https://github.com/wix/react-native-navigation/issues/3549#issuecomment-411800487) but it is not the real React Context API behavior. (https://github.com/wix/react-native-navigation/issues/3549#issuecomment-427603125)

How to load Google Places API in React Native?

I am trying to use the Google Places API in react native. I first tried using fetch to make requests directly, but I just saw that you have to use the existing classes/objects provided by Google, like the PlacesService. Searching for React Native libraries that include the API objects for you just brings up some that do the autocomplete feature and not much else.
The Places API docs say to load the library using this url: <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places"></script>
This is straightforward to me in regular web dev, but not in react native. What is the standard procedure for loading a library like this in React Native?
Right now I have copy and pasted the JS contents from the link above into a file in my React Native project. But, I don't even know how to export it as I can't really tell what the name of the object/function is. google ? google.maps ?
Right now I am doing:
export default google.maps
and also tried
export default google
but these both throw this error:
cannot read property 'createElement' of undefined
This is my first React Native project, so I'm sorry if this is a basic question.
Thanks for the help.
but I just saw that you have to use the existing classes/objects provided by Google
I'm not sure what you mean by that. Places api can be done via fetch/api request. Look at how react-native-google-places does it at https://github.com/FaridSafi/react-native-google-places-autocomplete/blob/master/GooglePlacesAutocomplete.js#L227
They use a new XMLHttpRequest(); but fetch() would work as well. It is web api and I don't think you need to run any external javascript/load any external js files.