Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3313 | Rev 3416 | 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, isLoading: 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>
  )
}