将Geofire与React一起使用

问题描述 投票:0回答:1

我正在尝试在使用React.js构建的Web应用程序中使用Geofire。

我已经通过:安装了geofire,

npm install geofire

我的职能是:

const updateCoords = (lat,lng)=>{
  var firebaseRef = firebase.database().ref("locations");
  var geofireRef = new Geofire(firebaseRef);
  
  geofireRef.set("user", [lat,lng]).then(function() {
    console.log("User added to Geofire");
    }, 
    function(error) {
      console.log("Error: " + error);
    });
}

但是每次我调用它时,都会出现以下错误:

'Geofire' is not defined 

任何解决方案?

P.S。 Firebase已安装]

我正在尝试在用React.js构建的Web应用程序中使用Geofire。我已经通过以下方式安装了geofire:npm install geofire我的功能是:const updateCoords =(lat,lng)=> {var ...

javascript reactjs firebase geofire
1个回答
0
投票

使用global variables时,所有window都映射到create-react-app对象>>

const geofire = new window.Geofire()
© www.soinside.com 2019 - 2024. All rights reserved.