Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3432 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3432 Rev 3719
Línea 1... Línea 1...
1
import React, { createContext, useCallback } from 'react'
1
import React, { createContext, useCallback } from 'react';
2
 
2
 
3
import { useFetch } from '@hooks'
3
import { useFetch } from '@hooks';
4
 
4
 
5
export const MyProgressContext = createContext()
5
export const MyProgressContext = createContext();
6
 
6
 
7
export default function MyProgressProvider({ children }) {
7
export default function MyProgressProvider({ children }) {
8
  const { data: habits, isLoading: loading } = useFetch(
8
  const { data: habits, isLoading: loading } = useFetch('/helpers/habits-and-skills/my', []);
9
    '/helpers/habits-and-skills/my',
-
 
10
    []
-
 
11
  )
-
 
12
 
9
 
13
  const getHabitById = useCallback(
10
  const getHabitById = useCallback(
14
    (habitId) => habits.find((habit) => habit.uuid === habitId),
11
    (habitId) => habits.find((habit) => habit.uuid === habitId),
15
    [habits]
12
    [habits]
16
  )
13
  );
17
 
14
 
18
  return (
15
  return (
19
    <MyProgressContext.Provider value={{ loading, habits, getHabitById }}>
16
    <MyProgressContext.Provider value={{ loading, habits, getHabitById }}>
20
      {children}
17
      {children}
21
    </MyProgressContext.Provider>
18
    </MyProgressContext.Provider>
22
  )
19
  );
23
}
20
}