反应原生 | react-native-google-signin
在我安装 react-native-google-sigin 之后
npm i react-native-google-signin
Run Code Online (Sandbox Code Playgroud)
它在应用程序启动时突然崩溃(强制关闭),我已经完成了 github 文档中说明的所有步骤,但是当我运行我的应用程序时它立即崩溃,日志中没有给出任何错误。( android-log 和 adb logcat *:S ReactNative:V ReactNativeJS:V 都没有)
这是我的代码:
构建.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
googlePlayServicesAuthVersion = "16.0.1" // <--- use this version or newer
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.1")
classpath 'com.android.tools.build:gradle:3.1.2' // <--- use this …Run Code Online (Sandbox Code Playgroud) 有很多关于如何在类组件中使用react-native-maps的示例,但我还没有找到那些带有无状态组件的示例。我使用无状态组件来访问全局状态。在获得用户的位置后,我需要将 MapView 的相机视图从初始区域移动,在互联网上搜索后,我不知怎的最终得到了这段不起作用的代码。
import React, { useState, useEffect, useRef } from 'react'
import MapView, { Marker, PROVIDER_GOOGLE } from 'react-native-maps';
...
const Explore = props => {
const [userCoords, setUserCoords] = useState({
latitude: 0,
longitude: 0
})
const mapRef = useRef(null);
onMapReady = () => {
getUserLocation()
}
getUserLocation = async () => {
Geolocation.getCurrentPosition(
async (position) => {
setUserCoords(position.coords)
mapRef.animateToRegion({
latitude: position.coords.latitude,
longitude: position.coords.longitude,
})
},
async (error) => {
// See error …Run Code Online (Sandbox Code Playgroud) javascript google-maps react-native react-native-maps react-hooks