Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React reading from firebase, getting error

I am trying to get data from firebase collection but getting error, can anybody help? I am getting this error

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:

here is my code.

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)

I have tried this export but same error

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

here is my 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"
]
}
like image 608
Ali Avatar asked Dec 18 '18 08:12

Ali


1 Answers

The error is quite clear, you are using react-redux-firebase:^2.2.5 while you need to use v3, because you are using react-redux: ^6.0.0.

You have to update react-redux-firebase

like image 110
Kabbany Avatar answered Sep 28 '22 05:09

Kabbany