OrderBy not returning any transactions at all
See original GitHub issueDo you want to request a feature or report a bug?
This is a bug. I notice quite a few open OrderBy related issues, but this one seems to be even more opaque. However, I can see it’s not happening to other people, so I suspect it’s at least partially related to my setup. But my setup is very normal.
What is the current behavior?
Adding an orderBy
clause to any firestoreConnect
component causes no data to be loaded:
export default compose(
connect(mapStateToProps, mapDispatchToProps),
firestoreConnect((props) => {
return [
{
collection: 'categories',
where: [['uid', '==', props.uid],],
orderBy: [['name', 'asc']] // doesn't work
// orderBy: ['name'] // doesn't work
// orderBy: 'name' // Nope
}
]
}),
)(CategoryChooser)
What is the expected behavior?
Elements should be returned, preferably in the requested order.
Which versions of dependencies, and which browser are affected by this issue? Did this work in previous versions or setups?
It’s behaving the same in 0.5.7 and 0.6.0-alpha2, under firefox on Fedora Linux 28.
The JS project was created with create-react-app. Here are the deps from my package.json:
"dependencies": {
"firebase": "^5.3.1",
"moment": "^2.22.2",
"object-hash": "^1.3.0",
"papaparse": "^4.6.0",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-redux": "^5.0.7",
"react-redux-firebase": "^2.1.7",
"react-router-dom": "^4.3.1",
"react-scripts": "^2.0.0-next.3e165448",
"react-social-login-buttons": "^2.1.2",
"redux": "^4.0.0",
"redux-firestore": "^0.6.0-alpha.2",
"redux-thunk": "^2.3.0"
},
Steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.
I suspect there will be some back and forth on this, but my setup is pretty generic. I’m composing my component as shown above, and I have my store configured as follows
import firebaseConfig from '../firebaseConfig.js'
import { createStore, compose, applyMiddleware } from 'redux'
import thunk from "redux-thunk"
import { reactReduxFirebase, getFirebase } from 'react-redux-firebase'
import { reduxFirestore } from 'redux-firestore'
import { initialState, rootReducer } from './reducers'
import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'
firebase.initializeApp(firebaseConfig)
const fs = firebase.firestore()
const ReactReduxFirebaseConfig = {
userProfile: 'users',
useFirestoreForProfile: true,
enableLogging: true,
}
const enhancers = [
reactReduxFirebase(firebase, ReactReduxFirebaseConfig),
reduxFirestore(firebase)
]
const composedEnhancers = compose(
...enhancers
)
const store = createStore(rootReducer, initialState, composedEnhancers)
export default store
For completeness, my reducers are defined correctly (everything works unless I orderBy):
import { combineReducers } from 'redux'
import { firebaseReducer } from 'react-redux-firebase'
import { firestoreReducer } from 'redux-firestore'
import { account_reducer } from './accounts'
import { transaction_reducer } from './transactions'
export const initialState = {}
export const rootReducer = combineReducers({
firebase: firebaseReducer,
firestore: firestoreReducer,
accounts: account_reducer,
transactions: transaction_reducer
})
There are no error messages in the console. I disabled redux-dev-tools to make sure it wasn’t conflicting somehow, but when it was on, it was showing an uninformative error returned from firebase:
errors: {
byQuery: {
'categories?where=uid:==:PijZAm394pMu24jSjAM2yVLfPLZ2': {
code: 'failed-precondition',
name: 'FirebaseError'
}
},
allIds: [
'categories?where=uid:==:PijZAm394pMu24jSjAM2yVLfPLZ2'
]
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
@prescottprue Bingo!
Putting
reduxFirestore
first logged the error. It does seem to be getting overwritten byreactReduxFirebase
I had enabled logErrors and not seen anything in the console, but that was probably due to not looking correctly. It was getting pretty late at night when I gave up. 😉 I think all this really needs is a documentation update – more clarity on what logErrors does and maybe a faq entry on indexes.