react-native : The term 'react-native' is not recognized
as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and
try again.
At line:1 char:1
This code in one of my applications works smoothly. On rendering the screen it shows my currentpositon in the intial region. However this doesn't work for my other applications, I wonder why? This is the error it shows
. Please I would need a code that would allow me show my current location, immediately the my screen renders. Note: I am developping for Android.
Environment
react-native : The term 'react-native' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
Platforms
Android
Versions
Description
`import { View, useWindowDimensions, PermissionsAndroid, Platform, Pressable, ActivityIndicator } from 'react-native' import React, {useState, useEffect} from 'react' import Geolocation from '@react-native-community/geolocation'; import MapView, {PROVIDER_GOOGLE, Marker} from 'react-native-maps';
const GOOGLE_MAPS_APIKEY = '*';
const HomeScreen = () => { const {width, height}= useWindowDimensions() const [myPosition, setMyPosition] = useState(null)
useEffect(() => { const requestLocationPermission = async () => { if (Platform.OS === 'android') { const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, { title: 'Atua Location Request', message: 'Atua needs access to your location.', buttonNeutral: 'Ask Me Later', buttonNegative: 'Cancel', buttonPositive: 'OK', }, ); if (granted === PermissionsAndroid.RESULTS.DENIED) { console.log('Location permission denied'); return; } }
}, []);
return (
) }
export default HomeScreen`
This code in one of my applications works smoothly. On rendering the screen it shows my currentpositon in the intial region. However this doesn't work for my other applications, I wonder why? This is the error it shows . Please I would need a code that would allow me show my current location, immediately the my screen renders. Note: I am developping for Android.
Reproducible Demo