Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3314 | Rev 3432 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import React, { createContext, useCallback } from "react";

import { useFetch } from "@hooks";

export const MyProgressContext = createContext();

export default function MyProgressProvider({ children }) {
  const { data: habits, loading: loading } = useFetch(
    "/helpers/habits-and-skills/my",
    []
  );

  const getHabitById = useCallback(
    (habitId) => habits.find((habit) => habit.uuid === habitId),
    [habits]
  );

  return (
    <MyProgressContext.Provider value={{ loading, habits, getHabitById }}>
      {children}
    </MyProgressContext.Provider>
  );
}