I'm designing an application in react native for medical use case. The idea is to record some audio and to send it to a local server. Therefore, the ip adress is defined at runtime.
Previously, I used a global const as adress (code below).
const url = 'http://192.168.43.56:5000/';const checkIsServerOnline = async (): Promise<string> => axios.get(url, { timeout: 5000, });
Now I would like to retrieve the url from a redux (persistant) store before using the function. I tried something like that, but it didn't worked:
function CheckIsServerOnline(): AxiosPromise { const { ipAdress } = useSelector( (state: RootState) => state.config ); return axios.get(ipAdress, { timeout: 5000, });}
The error message it returned:
Invalid hook call. Hooks can only be called inside of the body of afunction component. This could happen for one of the followingreasons:
- You might have mismatching versions of React and the renderer (such as React DOM)
- You might be breaking the Rules of Hooks
- You might have more than one copy of React in the same app
Do you have any idea how I would be able to retrieve the value from the redux state ?
(Apologies for the begineer question)