标签: react-redux-firebase

react-redux v6需要v3。*。*版本的react-redux-firebase

我一直在使用react-redux-firebase进行一个项目,该项目以前对我有用。今天我得到以下错误:

chrome错误消息

我不确定该错误是否在代码中的其他地方,或者我是否必须将react-redux-firebase更新到版本3 ,目前似乎还不存在。其他人遇到过这个问题吗?如有任何建议,我将不胜感激。

这是我的package.json中的依赖项:

"dependencies": { "firebase": "^5.7.0", "react": "^16.6.3", "react-dom": "^16.6.3", "react-redux": "^6.0.0", "react-redux-firebase": "^2.2.5", "react-router-dom": "^4.3.1", "react-scripts": "2.1.1", "redux": "^4.0.1", "redux-firestore": "^0.6.0", "redux-thunk": "^2.3.0" },

这是我的index.js文件的样子:

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import { 
  createStore, 
  applyMiddleware, 
  compose 
} from 'redux';
import rootReducer from './store/reducers/index';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';
import { reduxFirestore, getFirestore } from 'redux-firestore';
import { …
Run Code Online (Sandbox Code Playgroud)

version reactjs react-redux react-redux-firebase

14
推荐指数
2
解决办法
6336
查看次数

“TypeError: Object(...) is not a function” react-redux-firebase

我正在尝试在 React 中创建一个项目,并且正在使用 Firebase。在我的 react-redux-firebase 项目中,一行代码出错,但我无法修复。我该如何解决这个“TypeError: Object(...) is not a function”

我已经搜索过这个问题,但无法解决这个问题。

我正在关注反应版本为 16.4.1 的教程。我不确定这是不是问题

index.js 文件

import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import { createStore, applyMiddleware, compose } from "redux";
import rootReducer from "./store/reducers/rootReducer";
import { Provider } from "react-redux";
import thunk from "redux-thunk";
import { reduxFirestore, getFirestore } from "redux-firestore";
import { reactReduxFirebase, getFirebase } from "react-redux-firebase";
import fbConfig from "./config/fbConfig";

const store = …
Run Code Online (Sandbox Code Playgroud)

npm firebase reactjs react-redux react-redux-firebase

9
推荐指数
2
解决办法
5241
查看次数

如何使firestoreConnect指向React-Redux-Firebase中的嵌套集合?

下一行直接指向firestoreConnect标有的我的收藏projects

 { collection: 'projects' }
Run Code Online (Sandbox Code Playgroud)

当项目集合直接位于根目录下时,它将起作用:

root/
  projects/
Run Code Online (Sandbox Code Playgroud)

但是,如果项目集合被本身位于另一个集合中的文档所引用,例如:

root/
  users/
    alice/
      projects/
Run Code Online (Sandbox Code Playgroud)

我怎么点firestoreConnectprojects集合?

该文档对此未作说明。

链接到视频
import React, { Component } from 'react'
import ProjectList from '../projects/ProjectList'
import Notifications from './Notifications'
import { connect } from 'react-redux'
import { firestoreConnect } from 'react-redux-firebase'
import { compose } from 'redux'
import { Redirect } from 'react-router-dom'

class Dashboard extends Component {...}

const mapStateToProps = (state) => {
  // console.log(state);
  return {
    projects: state.firestore.ordered.projects, …
Run Code Online (Sandbox Code Playgroud)

firebase reactjs react-redux google-cloud-firestore react-redux-firebase

7
推荐指数
1
解决办法
1894
查看次数

Firestore通过数组的字段值查询

我正在尝试运行一个简单的查询,在其中搜索包含对象数组内的值的文档。

例如,看一下我的数据库结构:

消防员数据库

我想运行类似于此的查询:

db.collection('identites').where("partyMembers", "array-contains", {name: "John Travolta"})
Run Code Online (Sandbox Code Playgroud)

实现此目标的正确方法是什么,Firestore是否有可能?

谢谢。

firebase reactjs google-cloud-firestore react-redux-firebase

6
推荐指数
2
解决办法
1383
查看次数

如何使用 react-redux-firebase 将“auth”或“profile”对象传递给 firestoreConnect()?

我不知道如何将 'profile' 或 'auth' props 传递给 firestoreConnect() 函数,以便根据用户 ID 或其他一些键查询集合或文档(我的代码片段如下)。

我可以在我的 jsx 代码中访问 'auth' 和 'profile' 对象,但我找不到在 firestoreConnect() 函数中使用它们的方法(我收到一个错误:)TypeError: Cannot read property 'uid' of undefined。如果我对一些 uid 进行硬编码,则一切正常,但我无法将其作为 props 值传递。

任何建议都非常感谢!

export default compose(
  firebaseConnect(),
  firestoreConnect(props => [{ collection: 'projects', where: [['uid', '==', props.auth.uid]] }]), <<--THIS LINE DOES NOT WORK
  connect((state, props) => ({
    projects: state.firestore.ordered.projects,
    profile: state.firebase.profile,
    auth: state.firebase.auth,
  }))
)(Projects);
Run Code Online (Sandbox Code Playgroud)

firebase reactjs react-redux-firebase

5
推荐指数
1
解决办法
1093
查看次数

如何使用react-redux-firebase从firestore获取子集合

我无法从 Firestore 数据中获取子集合。

我按照文档here。并且还看了很多其他类似的问题。

我似乎无法获得我想要获得的数据数组。

我的代码:

import "../../styles/projects/ProjectDashboard.css";
import ProjectList from "./ProjectList";
import { connect } from "react-redux";
import { firestoreConnect } from "react-redux-firebase";
import { compose } from "redux";
import { Redirect } from "react-router-dom";

export class ProjectDashboard extends Component {
  render() {
    const { projects, auth } = this.props;
    if (!auth.uid) return <Redirect to="/sigin" />;
    return (
      <div className="container">
        <h2>Projects</h2>
        <ProjectList projects={projects} />
      </div>
    );
  }
}

const mapStateToProps = state => {
  console.log(state);
  return { …
Run Code Online (Sandbox Code Playgroud)

firebase reactjs react-redux google-cloud-firestore react-redux-firebase

5
推荐指数
1
解决办法
2280
查看次数

react-native-firebase vs react-redux-firebase?

背景:我已开始使用带有react-native的react-native-firebase与Cloud Firestore集成。我将开始将redux引入我的测试应用程序。

问题-作为我在这里选择的库,react-native-firebase是否可以继续?(与迁移到react-redux-firebase相比)

当您将一个与另一个相对时,是否有一种简单的方法可以总结两个库之间的差异?我注意到使用react-native-firebase时,IOS和Android的安装相当复杂,因此我不确定react-redux-firebase是否使此操作更容易,但是如果混合使用,您是否会丢失任何东西?

react-native-firebase react-redux-firebase

4
推荐指数
1
解决办法
2272
查看次数

如何使用 v3.0.0 查找 firebaseAuthIsReady 是否可用?

在带有 v3.0.0 的 react-redux-firebase 中,有什么替代方案可以确定 auth 是否准备就绪 - 首次渲染?在这种情况下,问题是商店不包含 firebaseAuthIsReady 还是我遗漏了什么?

//ReactReduxFirebaseProvider v3.0.0
const rrfConfig = { 
  userProfile: 'users',
  attachAuthIsReady: true,
  firebaseStateName: 'firebase'
}

//const store = configureStore(initialState, history, rrfConfig);
const store = configureStore(initialState, history);


const rrfProps = {
  firebase,
  config: rrfConfig,
  dispatch: store.dispatch,
  createFirestoreInstance
}

const MOUNT_NODE = document.getElementById('root')
//store.firebaseAuthIsReady.then(() => {
  ReactDOM.render(
    <MuiThemeProvider theme={theme}>
      <Provider store={store}>
        <ReactReduxFirebaseProvider {...rrfProps}>
          <ConnectedRouter history={history}>
            <App />
          </ConnectedRouter>
        </ReactReduxFirebaseProvider>
      </Provider>
    </MuiThemeProvider>,
    MOUNT_NODE
  );
Run Code Online (Sandbox Code Playgroud)

firebase reactjs react-redux-firebase

3
推荐指数
1
解决办法
1923
查看次数

Object(...) 不是 applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })) 的函数错误

我在我的项目中遇到了一个错误,当我想使用我的 CreateProject 反应组件动态添加数据时,我使用 React/Redux/Firebase 工具创建了它我收到了这个错误:× TypeError: Object(...) is not a function

索引.js

import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import { createStore, applyMiddleware, compose } from "redux";
import rootReducer from "./store/reducers/rootReducer";
import { Provider } from "react-redux";
import thunk from "redux-thunk";
import { reduxFirestore, getFirestore } from "redux-firestore";
import { reactReduxFirebase, getFirebase } from "react-redux-firebase";
import fbConfig from "./config/fbConfig"

const store = createStore(
  rootReducer,
  compose(
    applyMiddleware(thunk.withExtraArgument({ getFirebase, …
Run Code Online (Sandbox Code Playgroud)

firebase reactjs redux react-redux-firebase

3
推荐指数
1
解决办法
2229
查看次数

如何从react-firebase获取有效令牌以进行nodesjs服务器验证

我有一个reactJS Web应用程序,我正在使用react-redux-firebase进行身份验证,它工作正常。

现在我想添加一个自己的nodejs服务器(后面有一个小数据库),我读到我可以使用react webapp登录中的firebase令牌来对nodeJs服务器上的用户进行身份验证,然后再让他对数据库进行更改。

但我得到了错误

No pem found for envelope: {"alg":"RS256","kid":"f5c9aebe234da6016bd7b949168b8cd5b4ec9eeb","typ":"JWT"}
Run Code Online (Sandbox Code Playgroud)

这就是我在客户端获取令牌并将其发送到服务器的方式


async function updateDataInDatabase2(data, dispatch, getState) {
    try {
        await axios.post(`http://localhost:5000/app/todo/data`, JSON.stringify(data), {
            headers: { 'Content-Type': 'application/json', 'firebase-idToken': getState().firebase.auth.stsTokenManager.accessToken },
        });
    } catch (err) {
        console.log(err.message);
    }
}
Run Code Online (Sandbox Code Playgroud)

我发送的令牌如下所示:

'eyJhbGciOiJSUzI1NiIsImtpZCI6ImY1YzlhZWJlMjM0ZGE2MDE2YmQ3Yjk0OTE2OGI4Y2Q1YjRlYzllZWIiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL3NlY3VyZXRva2VuLmdvb2dsZS5jb20vam9ycm9jaC1jb25zdWx0aW5nIiwiYXVkIjoiam9ycm9jaC1jb25zdWx0aW5nIiwiYXV0aF90aW1lIjoxNTkwMDU5Njk5LCJ1c2VyX2lkIjoiVkFXSEFZVXdXS2g5akJkbE82QWFOc0ZUVFJwMSIsInN1YiI6IlZBV0hBWVV3V0toOWpCZGxPNkFhTnNGVFRScDEiLCJpYXQiOjE1OTAwNTk2OTksImV4cCI6MTU5MDA2MzI5OSwiZW1haWwiOiJtYXJrdXNhY3Rpb25qYWNrc29uQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJmaXJlYmFzZSI6eyJpZGVudGl0aWVzIjp7ImVtYWlsIjpbIm1hcmt1c2FjdGlvbmphY2tzb25AZ21haWwuY29tIl19LCJzaWduX2luX3Byb3ZpZGVyIjoicGFzc3dvcmQifX0.KRWI4drcSSU-3YVALR4kJlLdbB9JfhSvbhsa4nR42r41IQkeRj8uIZRkA6-kmprpohlRt8v3ZlM1NsY37eNeHsI1x-KIYlVmcpE4GDETrTMNQ-NdfoyIAFqij79iPi4b7y5uDy6uFLLiKgoQKUJKIT_OFDcM1vUXeLrsA0Jn4eoA7w8wMHTqCA0vYU2YutLuBydpfdElGM0LR3yqWAf6jJFjRu45vyY1JQsI2utTBCv21B4_IDFiN7ov8NqUFjX5CHkRNiipF9P6H9USYvcPTg6AQYfMhMd8V1rtT9_EXPZMNEMnR72sIWG9Y5-Fq4fT7K1mtj7OZlKURGfKSdyybA'
Run Code Online (Sandbox Code Playgroud)

这似乎是一个有效的令牌。

我也尝试这样做:

getFirebase().auth().currentUser.getIdToken()
Run Code Online (Sandbox Code Playgroud)

但这提供了一个像这样的对象:

const token1 = {
    a: 2,
    b: null,
    c: null,
    f: null,
    g: false,
    h: false,
    i:
        'eyJhbGciOiJSUzI1NiIsImtpZCI6ImY1YzlhZWJlMjM0ZGE2MDE2YmQ3Yjk0OTE2OGI4Y2Q1YjRlYzllZWIiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL3NlY3VyZXRva2VuLmdvb2dsZS5jb20vam9ycm9jaC1jb25zdWx0aW5nIiwiYXVkIjoiam9ycm9jaC1jb25zdWx0aW5nIiwiYXV0aF90aW1lIjoxNTkwMDU5Njk5LCJ1c2VyX2lkIjoiVkFXSEFZVXdXS2g5akJkbE82QWFOc0ZUVFJwMSIsInN1YiI6IlZBV0hBWVV3V0toOWpCZGxPNkFhTnNGVFRScDEiLCJpYXQiOjE1OTAwNTk2OTksImV4cCI6MTU5MDA2MzI5OSwiZW1haWwiOiJtYXJrdXNhY3Rpb25qYWNrc29uQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJmaXJlYmFzZSI6eyJpZGVudGl0aWVzIjp7ImVtYWlsIjpbIm1hcmt1c2FjdGlvbmphY2tzb25AZ21haWwuY29tIl19LCJzaWduX2luX3Byb3ZpZGVyIjoicGFzc3dvcmQifX0.KRWI4drcSSU-3YVALR4kJlLdbB9JfhSvbhsa4nR42r41IQkeRj8uIZRkA6-kmprpohlRt8v3ZlM1NsY37eNeHsI1x-KIYlVmcpE4GDETrTMNQ-NdfoyIAFqij79iPi4b7y5uDy6uFLLiKgoQKUJKIT_OFDcM1vUXeLrsA0Jn4eoA7w8wMHTqCA0vYU2YutLuBydpfdElGM0LR3yqWAf6jJFjRu45vyY1JQsI2utTBCv21B4_IDFiN7ov8NqUFjX5CHkRNiipF9P6H9USYvcPTg6AQYfMhMd8V1rtT9_EXPZMNEMnR72sIWG9Y5-Fq4fT7K1mtj7OZlKURGfKSdyybA',
};
Run Code Online (Sandbox Code Playgroud)

使用该对象可能不正确。JSON.stringyfy 给我一个解析错误。所以我决定将String发送到“i”属性后面,这与上面相同。

在服务器端,我尝试像这样验证它:

router.post('/data', async (req, res) => {
    const idToken = req.header('firebase-idToken');
    const userid = …
Run Code Online (Sandbox Code Playgroud)

node.js firebase google-oauth react-redux-firebase

3
推荐指数
1
解决办法
2163
查看次数

redux-firestore 侦听器错误:FirebaseError:权限缺失或不足。?

我是 firebase 的新手,我在控制台中有一个错误,我真的不知道它的来源:

redux-firestore listener error: FirebaseError: Missing or insufficient permissions.
Run Code Online (Sandbox Code Playgroud)

我不知道这是否足以解释我的问题,但是因为我是新手firebasefirestore我无法解释更多或带来一些代码,一切正常,但突然出现此错误,可能是什么原因造成的那个错误??怎么修??

firebase google-cloud-firestore react-redux-firebase redux-firestore

2
推荐指数
1
解决办法
803
查看次数

firebase.database() 不是反应中的函数错误

为了提供一些上下文,我尝试使用 redux-toolkit 和 react-redux-firebase 设置我的 React 应用程序(需要 firebase 实时数据库)。

我按照react-redux-firebase自述文件创建了这个文件


import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import { store } from "./app/store";
import { Provider } from "react-redux";
import * as serviceWorker from "./serviceWorker";
import { initializeApp } from "firebase/app";  
import "firebase/database"; // to enable using firebase RTD
import { ReactReduxFirebaseProvider } from "react-redux-firebase";

const fbConfig = {
    apiKey: "**",
    authDomain: "**",
    projectId: "**",
    storageBucket: "**",
    messagingSenderId: "**",
    appId: "**",
    measurementId: "**", …
Run Code Online (Sandbox Code Playgroud)

javascript firebase reactjs redux react-redux-firebase

2
推荐指数
1
解决办法
971
查看次数