Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3432 | Rev 3692 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3432 Rev 3642
Línea 1... Línea 1...
1
import { useMemo } from 'react'
1
import { useMemo } from 'react';
2
import { useFetch } from '@hooks'
2
import { useFetch } from '@hooks';
-
 
3
import { formatObjectToArray } from '@utils';
Línea 3... Línea 4...
3
 
4
 
4
export function useFetchHelper(helper = '') {
5
export function useFetchHelper(helper = '') {
Línea 5... Línea 6...
5
  const { data, isLoading } = useFetch(`/helpers/${helper}`, [])
6
  const { data, isLoading } = useFetch(`/helpers/${helper}`, []);
6
 
7
 
7
  const parseData = useMemo(() => {
8
  const parseData = useMemo(() => {
8
    if (!Array.isArray(data)) {
-
 
9
      const adapterData = Object.entries(data).map(([key, value]) => {
9
    if (!data) return [];
Línea 10... Línea -...
10
        return { value: key, name: value }
-
 
11
      })
-
 
12
 
-
 
13
      return adapterData
-
 
14
    }
-
 
15
 
-
 
16
    return data
10
    return Array.isArray(data) ? data : formatObjectToArray(data);
17
  }, [data])
11
  }, [data]);