How to use the react-firebase-hooks/firestore.useCollection function in react-firebase-hooks

To help you get started, we’ve selected a few react-firebase-hooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bmcmahen / captioner / src / Editor.tsx View on Github external
firebase
      .firestore()
      .collection("captions")
      .doc(id)
  );

  const [name, setName] = React.useState(meta ? meta.get("title") : "");

  const subcollection = firebase
    .firestore()
    .collection("captions")
    .doc(id)
    .collection("entries");

  // load the actual captions themselves
  const captions = useCollection(subcollection.orderBy("startTime"));

  // the current video url
  const [video, setVideo] = React.useState(
    meta ? meta.get("url") : null
  );

  React.useEffect(() => {
    if (meta && meta.get("url") !== video && meta.get("url")) {
      setVideo(meta.get("url"));
    }

    if (meta && meta.get("title") !== name) {
      setName(meta.get("title"));
    }
  }, [meta]);
github bmcmahen / julienne / src / hooks / with-follow-request-count.ts View on Github external
export function useFollowRequests() {
  const user = useSession();
  const { error, loading, value } = useCollection(
    firebase
      .firestore()
      .collection("relations")
      .where("toUserId", "==", user.uid)
      .where("confirmed", "==", false)
      .limit(50)
  );

  return {
    error,
    loading,
    value
  };
}
github equithon / site-main / src / app / views / appreview / AppReviewViewContainer.jsx View on Github external
const AppReviewViewContainer = ({ appsNeedingReview, submitReviewOfApp }) => {
  const { state, dispatch } = useContext(SiteContext);
  const { error, loading, value } = useCollection(appsNeedingReview);

  const valueFetched = error || loading || !value ? "WAITING" : value.data();
  let curAppReview =
    state.curAppReview && state.curAppReview !== "SUBMITTED"
      ? state.curAppReview
      : valueFetched;

  const updateReviewInState = updatedReview =>
    dispatch({ type: "UPDATE_APP_REVIEW", data: updatedReview });
  const submitReviewInState = () => {
    dispatch({ type: "SUBMIT_APP_REVIEW" });
    submitReviewOfApp();
    curAppReview = valueFetched;
  };

  return (
github bmcmahen / captioner / src / Me.tsx View on Github external
export const Me: React.FunctionComponent = props => {
  const user = useSession();
  const theme = useTheme();
  const toast = useToast();

  const [newProjectId, setNewProjectId] = React.useState();

  const { error, loading, value } = useCollection(
    firebase
      .firestore()
      .collection("captions")
      .where("uid", "==", user!.uid)
  );

  const { loading: creatingProject, create } = useCreateProject();

  function createProject() {
    create()
      .then(result => {
        setNewProjectId(result.id);
      })
      .catch(err => {
        toast({
          title: "An error occurred while creating your project",

react-firebase-hooks

React Hooks for Firebase

Apache-2.0
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis