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) => {
setLoading(true);
const response = await apiFunc(...args);
setLoading(false);
setError(!response.ok);
setData(response.data);
return response;
};
return { data, error, loading, request };
};
and the error is:
ReferenceError: useApi is not defined
with line 3 pointed out.