Baffled! useApi hook causing browser error but working fine elsewhere

I’ve been working through The Ultimate React Native Series: Advanced Concepts.

Having added the useApi hook suddenly I am getting “ReferenceError: useApi is not defined” but only in the web browser. There is no problem in the Android emulator or via Expo app on Android or iOS. Totally baffled by it - can anyone help?

The useApi.js is as follows

import { useState } from 'react';

export default useApi = (apiFunc) => {
    const [data, setData] = useState([]);
    const [error, setError] = useState(false);
    const [loading, setLoading] = useState(false);
    const request = async (...args) => {
        const response = await apiFunc(...args);
        return response;

return { data, error, loading, request };


and the error is:

ReferenceError: useApi is not defined

with line 3 pointed out.

Interesting observation. I don’t have an answer but I haven’t been able to get the course app to run in the browser at any time. I get errors related to issues with some of the node modules, such as this one: ```Module not found: Can’t resolve ‘…/Utilities/Platform’

So far, however, the apps seem to run fine in the simulators and on actual hardware.

Same issue its working fine in real device and emulator but not in web

Try this instead:

const useApi = (apiFunc) => {
  // hook code

export default useApi;

Or this:

export default function useApi(apiFunc) {
  // hook code

sadly no luck even i am wondering in Location hook he is using a same userLocation

export default function userLocation() {