When i try to setup ongoing react-native project in that one of the plugin is react-native-fetch-blob i'll try many but can't resolve this issue.
also i remove that plugin from app and resetup all step from npm react-native-fetch-blob
after following all step getting same issue.
`RNFetchBlob.fetch('POST', 'api', {
'Content-Type': 'application/multipart/form-data'
}, [
{name: 'file', filename: filename, data: RNFetchBlob.wrap(PictureURI)}
])
.then((responseData) => {
// console.log("image uploaded",responseData);
// console.log("----------Upload Image Test---RESPONSE---------");
})
.catch(err => {
// console.log(err);
// console.log("----------Upload Image Test---RESPONSE--ERROR-------");
})`
in this plugin i'm only used the fetch method but my project gives me error mkdir method.
Resolve this issue following steps:
react-native unlink react-native-fetch-blob
npm uninstall react-native-fetch-blob --save
yarn add react-native-fetch-blob (assuming your system already
installed yarn)
RNFB_ANDROID_PERMISSIONS=true react-native link
then uninstall app from device/simulator/emulator and run command
react-native run-android
work perfect.
:)
Related
I am trying to get current country of device in but didn't find anything. Is there something to do so in React Native?
I tried using react-native-device-info but it is also not supporting but in previous version it can be get by getDeviceCountry(). Now for the latest version it is showing error:
TypeError: _reactNativeDeviceInfo.default.getDeviceCountry is not a
function. (In '_reactNativeDeviceInfo.default.getDeviceCountry()',
'_reactNativeDeviceInfo.default.getDeviceCountry' is undefined)
According to the documentation of react-native-device-info for latest version, they have moved some of their apis to react-native-localize to reduce duplication in the react-native-community modules. react-native-localize worked perfectly for me.
Setup:
$ npm install --save react-native-localize
# --- or ---
$ yarn add react-native-localize
Usage:
import * as RNLocalize from "react-native-localize";
console.log(RNLocalize.getLocales());
console.log(RNLocalize.getCurrencies());
console.log(RNLocalize.getCountry());
console.log(RNLocalize.getCalendar());
console.log(RNLocalize.getTemperatureUnit());
console.log(RNLocalize.getTimeZone());
console.log(RNLocalize.uses24HourClock());
and many more. For detailed description please visit their official documentation by the given link: react-native-localize
Its solved my problem;
BREAKING CHANGE: remove is24Hour, getTimezone, isAutoTimeZone and isAutoDateAndTime, getDeviceLocale, getDeviceCountry, getPreferredLocales
This was the result of a survey. It removes API duplication in the react-native-community modules
Related PR: https://github.com/react-native-community/react-native-localize/pull/65
Use yarn add
https://github.com/mikehardy/react-native-localize.git#e062f0d2dc3171dc18fdb7b7139d347ad03933dc to maintain
isAutoTimeZone + isAutoDateAndTime until merged
The accepted answer didn't work for me, maybe due to https://github.com/zoontek/react-native-localize/issues/81.
However, Expo has something from its ecosystem, which worked out perfectly:
expo install expo-localization
import { getLocales } from 'expo-localization';
console.log(getLocales()[0].regionCode);
Edit: docs here https://docs.expo.io/versions/latest/sdk/localization/#localizationregion
Looks like it's a bug in the React Native. Please check their Troubleshooting section
Here is what they advice:
Seems to be a bug caused by react-native link. You can manually delete
libRNDeviceInfo-tvOS.a in Xcode -> [Your iOS build target] -> Build
Phrases -> Link Binary with Libraries.
Please use this package to get device country . to has different type of configs.
react-native-device-country
Some Examples
import DeviceCountry, {
TYPE_ANY,
TYPE_TELEPHONY,
TYPE_CONFIGURATION,
} from 'react-native-device-country';
DeviceCountry.getCountryCode()
.then((result) => {
console.log(result);
// {"code": "BY", "type": "telephony"}
})
.catch((e) => {
console.log(e);
});
DeviceCountry.getCountryCode(TYPE_TELEPHONY)
.then((result) => {
console.log(result);
// {"code": "BY", "type": "telephony"}
})
.catch((e) => {
console.log(e);
});
DeviceCountry.getCountryCode(TYPE_CONFIGURATION)
.then((result) => {
console.log(result);
// {"code": "BY", "type": "config"}
})
.catch((e) => {
console.log(e);
});
Environment: Android 6 Marshmallow and iOS(all versions)
Error: Android app with WebSockets is crashing with error:
WebSocketModule.close got 1 arguments, expected 3.
The error happens when I close the WebSocket connection just on Android, for instance:
this.ws = new WebSocket(url);
this.ws.onopen = () => {
const command = { command: 'JOIN', room: roonHash };
this.ws.send(JSON.stringify(command));
};
this.ws.onmessage = e => {
//more code here
};
// Finally:
this.ws.close();
iOS:
On iOS it works fine.
I'm using Expo v27 but I got the same error on v28.
Is there any workaround fixing that until the Expo/React Native team fixes it forever?
Expo v27
Update your React Native/Expo v27.0.0 to v27.0.2 on your package.json
Expo v28
Update your React Native/Expo v28.0.0 to v28.0.1 on your package.json
Procedures:
1) Go to your package.json file and change the version of your expo, for example:
From:
"react-native": "https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz",
To:
"react-native": "https://github.com/expo/react-native/archive/sdk-27.0.2.tar.gz",
2) Delete your node_modules:
$ rm -rf node_modules
3) Install it again:
$ yarn install
I am trying to use nativescript-sound package in my nativescript/vue-cli based app.I install nativescript-sound using
npm install --save nativescript-sound
After installing this i run npm clean and than try to call nativescript-sound on my project's main.js file
require("nativescript-vue").registerElement("sound", () => require("nativescript-sound").sound);
When i try to run
npm run watch:android
compiler showing me error.
Error
ERROR in ./src/main.js
Module not found: Error: Can't resolve 'nativescript-sound' in
'/home/darahat/Desktop/Rhymes/src'
# ./src/main.js
My Question is why it showing error?
Is nativescript-sound support nativescript/vue cli?
If not support which plugin i can use to add background sound and
click button sound?
I changed in
node_modules/nativescript-sound/package.json
"main": "sound.js",
to
"main": "sound",
and it works!
let Sound = require("nativescript-sound");
I'm using React Native and Firebase in my app. And out of nowhere I just started recieving this error:
SyntaxError: Unexpected end of JSON input.
at doWrite(_stream_writable.js)
at Promise.resolve.then.then.then.catch.then.message
and in my react packager it is pointing to this code:
onProfilesChange = async (snap) => {
var allProfilePromises = []
snap.forEach((child) => {
var profileId = child.val().profileId
var alreadyAdded = this.state.profiles.some(x => x.id === profileId)
if (alreadyAdded === false) {
var profilePromise = this.registerOnProfileChanges(profileId)
allProfilePromises.push(profilePromise)
}
})
await Promise.all(allProfilePromises)
var profileCount = snap.numChildren()
this.setState({ profiles: this.state.profiles, loading: false, profileCount: profileCount })
if (profileCount <= 0) {
this.getUserName()
}
}
which is being run when componentMount is called. Now the error is quite clear, but I don't know WHY it is being produced, nor how to get passed it. This code has worked for months without me changing anything to it.
Thank in advance.
try clearing cache and restart the server...
cd android & gradlew clean & cd .. & rm -rf node_modules/ & npm cache clean --force & yarn install & react-native run-android
you may want to use npm i instead of yarn install
I met the same problem. It is relevant to image.
I solved this by changing the version of react-native-img-cache.
run this:
npm install react-native-img-cache#1.4.0
I am trying to use firestack in my react-native application.
I did:
npm install react-native-firestack --save
but then when I try to link:
react-native link react-native-firestack
I get the error:
rnpm-install ERR! It seems something went wrong while linking. Error: spawn UNKNOWN
Do you have any ideas why is this?
As per my understanding try this:
First use rnpm link react-native-firestack
if it does not work then try this:
You can remove these lines from package.json:
"rnpm": {
"commands": {
"prelink": "node_modules/react-native-lock/bin/prepare.sh",
"postlink": "node_modules/react-native-lock/bin/cocoapods.sh"
}
}