Proyectos de Subversion LeadersLinked - SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3012 stevensc 1
import { useContext, useEffect } from 'react'
2671 stevensc 2
import { HabitsContext } from '@app/providers/habits'
3012 stevensc 3
import { useFetch } from './useFetch'
2671 stevensc 4
 
2774 stevensc 5
export function useHabits() {
3012 stevensc 6
  const { data: fetchedHabits, isLoading } = useFetch('/habits', [])
7
  const habitsState = useContext(HabitsContext)
8
 
9
  const { setHabits } = habitsState
10
 
11
  useEffect(() => {
12
    console.log(fetchedHabits)
13
    setHabits(fetchedHabits)
14
  }, [fetchedHabits])
15
 
16
  return { ...habitsState, loading: isLoading }
2671 stevensc 17
}