Redux persist imports not importing - react-native

Im following the documentation on the redux-persist github page but i dont know if they are for react native or not because im having issues with my imports. I am using Expo.
Heres what the documentation said you should use vs what i actually had to use:
import storage from 'redux-persist/lib/storage'
vs mine:
import storage from 'redux-persist/lib/defaults/asyncLocalStorage'
The next one i need to import is this
import { PersistGate } from 'redux-persist/integration/react'
However i cant figure out what file this is from at there is no 'integrations' folder.
Does anyone have any solution to this?

What makes you think that is not there? It is clearly part of the package as you can see here: https://unpkg.com/browse/redux-persist#6.0.0/integration/react/
Same for storage:
https://unpkg.com/browse/redux-persist#6.0.0/lib/storage/

Related

Using SASS in React Native

I'm trying to find a way to implement SASS in my react native project. All I found is this package react-native-sass-transformer, but it doesn't seem to work on my end. Tried looking for other way but all I see is approach in React instead. Does anyone know another way into implementing SASS in a react native cli project? Thank you!
I bet you're trying to use react native sass transformer with .tsx (typescript implementation), if it's the case, you just need to :
//#ts-ignore
import styles from './app.scss';
And then it should work.
You can also use: https://github.com/kristerkari/react-native-typed-sass-transformer to handle types (I didn't tried yet, but I'll !)
Good luck!

Not able to import #/screens/AreaChartScreen/chartAdds in react-native

I want to add Dots in my react native Line Chart component.
I have installed react-native-svg and react-native-svg-charts.
I need to import Dots, Line, Gradient from '#/screens/AreaChartScreen/chartAdds' but the import statement does not work.
Probably are your babel and jsonconfig configurations that are wrong; the configuration is more tricky than with next/react.
I saw this video and may help you.
https://youtu.be/03F0xzI9VnU :)

Using Import syntax in React native Image

Can I use import syntax instead of require as suggested by react native docs
I assume both are same. If not why? Will that improve the performance of loading images?
Yes, the latest React Native tutorials use the new import syntax.
The main difference is, import is ECMAScript 6(ES6) syntax and require is ECMAScript 5(ES5).
yes you can use import. require is old syntax and import is new one introduced in ES6.

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.

Application crashes after using react-native-chart-android

I am making an app using react native version 0.29. I need an chart library for my android app. After embedding react-native-chart-android in my app I got the following error.
I got the answer for the problem. This library is written for below RN v 0.25. So they are using
import React,{ requireNativeComponent, Component, PropTypes, View } from 'react-native';
in their import statements. For RN updated version they should have import React and Component from react.
For that I will raise a PR in Github.