continue generating flow, add backend connection on main tabs
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { useGlobal } from "reactn";
|
||||
import firebase from "../config/firebase";
|
||||
import useDataFromRef from "./useDataFromRef";
|
||||
|
||||
export default function useUserLikedProjects() {
|
||||
const [currentUID] = useGlobal("currentUID");
|
||||
|
||||
const { data, loading } = useDataFromRef({
|
||||
ref:
|
||||
currentUID
|
||||
? firebase
|
||||
.firestore()
|
||||
.collection("projects")
|
||||
.where("likedBy", "array-contains", currentUID)
|
||||
: null,
|
||||
simpleRef: false,
|
||||
listener: true,
|
||||
condition: !!currentUID,
|
||||
refreshArray: [currentUID],
|
||||
});
|
||||
|
||||
return { projects: Array.isArray(data) ? data : [], loading };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user