gpt4 book ai didi

reactjs - 从 firebase 进行 react 读取,出现错误

转载 作者:行者123 更新时间:2023-12-03 13:35:20 28 4
gpt4 key购买 nike

我正在尝试从 Firebase 集合中获取数据,但出现错误,有人可以帮忙吗?我收到此错误

Error: Context from react-redux not found. If you are using react-redux v6 a v3.. version of react-redux-firebase is required. Please checkout the v3 migration guide:

这是我的代码。

import React, { Component } from 'react'
import Notifications from './Notifications';
import ProjectList from '../projects/ProjectList';
import {connect} from 'react-redux';
import {firestoreConnect} from 'react-redux-firebase';
import {compose} from 'redux';
import { firebaseConnect, isLoaded, isEmpty } from 'react-redux-firebase'

class Dashboard extends Component {
render() {

return (
<div className="dashboard container">
<div className="row">
<div className="col s12 m6"><ProjectList projects={this.props.projects}></ProjectList></div>
<div className="col s12 m5 offset-m1"><Notifications></Notifications></div>
</div>
</div>
)
}
}
const mapStateToProps = (state) =>
{
console.log(state);
return ({projects:state.projectReducer.projects})
}
export default compose(firebaseConnect([
'projects'
]), connect(mapStateToProps)) (Dashboard)

我尝试过此导出,但出现同样的错误

export default compose(connect(mapStateToProps), firestoreConnect([
{collection:'project'}
])) (Dashboard)

这是我的 package.json

{
"name": "myproject",
"version": "0.1.0",
"private": true,
"dependencies": {
"firebase": "^5.7.0",
"firedux": "^1.1.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"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}

最佳答案

错误非常明显,您正在使用 react-redux-firebase :^2.2.5而您需要使用 v3,因为您正在使用 react-redux :^6.0.0 .

您必须更新react-redux-firebase

关于reactjs - 从 firebase 进行 react 读取,出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53828993/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com