Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
Why does default export add any type in Flow?

Currently trying to convert a part of the codebase into Flow. While I was tackling with API calls, I have created a hook to abstract the functionality. However when I tried to import it, the function always returned with a later-added any type.

useApi.js

// @flow
import {useState, useEffect} from 'react';

export default function useApi<T>(
    apiCall: (...args: any[]) => Promise<T>,
    initialValue:T[]=[]
): T[] {
    const [data, setData] = useState(initialValue);
    useEffect(() => {
        apiCall().then(setData).catch(console.error);
    }, [apiCall]);
    return data;
}

App.js

import './App.css';
import useApi from './hooks/useApi';
import { getOffers } from './service/Offers';
import { useCallback } from "react";
import Header from "./components/Header";
import Card from "./components/Card";

function App() {
  const getOffersMemo = useCallback(() => getOffers(), []);
  const offers = useApi(getOffersMemo); // type => OfferModel[] | any
  return (//SomeTemplate);
}

export default App;

However when I use export without default keyword it doesn't add any type. What is the reason for this behavior?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda