Reputation: 1672
I'm trying to configure react-redux-firebase to work with redux-firestore. I followed the example setup from the official Docs and everything seems to work until i wire up a component with firestorConnect from react-redux-firebase. As soon as the connected Component mounts I get the following error:
Uncaught Error: Collection is required to build query name
This is how I am attempting to connect my component:
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { firestoreConnect } from 'react-redux-firebase';
export class TestComponent extends Component {
render() {
return <div>test</div>;
}
}
export default compose(
firestoreConnect(['test']),
connect(state => ({
test: state.firestore.ordered.test
}))
)(TestComponent);
Update
The Problem could be resolved by specifying the collections in the following way:
firestoreConnect([{ collecion: 'test' }])
That's strange because the official Docs, state that the follwoing should also work.
import { compose } from 'redux'
import { connect } from 'react-redux'
import { firestoreConnect } from 'react-redux-firebase'
export default compose(
firestoreConnect(['todos']), // or { collection: 'todos' }
connect((state, props) => ({
todos: state.firestore.ordered.todos
}))
)(SomeComponent)
I'm puzzled.
Upvotes: 2
Views: 1127
Reputation: 9915
I just had the same error and in my case i was missing the collection
key in firestoreConnect
.
Wrong:
export default compose(
firestoreConnect([
{ projects: 'projects' }
]),
connect(mapStateToProps, mapDispatchToProps)
)(Header);
Right:
export default compose(
firestoreConnect([
{ collection: 'projects' }
]),
connect(mapStateToProps, mapDispatchToProps)
)(Header);
Upvotes: 1