Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!