prescottprue / react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
https://react-redux-firebase.com
MIT License
2.55k stars 556 forks source link

Cannot use orderBy() with "asc" and "desc". #835

Closed NikolaGrgicOld closed 4 years ago

NikolaGrgicOld commented 4 years ago

I am attempting to sort some news posts within my react-native application using orderBy() from newest to oldest. They are saved in Firestore. Whenever I use orderBy("date", "asc") or even orderBy("date", "desc") for that matter, it fails to retrieve any results.

My code for adding posts to Firestore looks like the following:

this.props.firestore.add({ collection : "posts" }, { ...details, date : firestore.Timestamp.fromDate(new Date()) });

I'm using the withFirestore HOC and calling orderBy() without the second parameter works without issue, but I'm looking to get my posts from newest to oldest and sorted by this date parameter.

My dependencies are as follows:

"react": "16.9.0" "react-native": "0.61.5" "react-native-firebase": "^5.5.6" "react-redux": "^7.1.1" "react-redux-firebase": "^3.0.0-beta.2" "redux": "^4.0.4" "redux-firestore": "^0.9.0"

I'm testing this out on an Android Emulator.