Open Kipitup opened 2 years ago
@ErnoW possible to have your opinion on this please ?
@ErnoW I still have the problem, please
Possibly what's happening is that an async request is made and not finished when the app is loaded. Did you wrap the router provider provider around the MoralisProvider, or the other way around? That might maybe also help 🤔 . Best is to have the MoralisProvider wrap the router provider.
<MoralisProvider>
<RouterProvider>
<App />
</RouterProvider>
</MoralisProvider>
Will look into it if we can cleanup async requests, not sure if it is always possible, and in most cases we don't even need it.
It should not impose any real issue in the app, but we will see if we can resolve this warning.
Thanks for your answer.
I was wrapping the router provider around the Moralis one. Changed it the other way around but still have the error.
Here is my index.js for more detail:
import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter } from "react-router-dom";
import "@/index.css";
import App from "@/App.jsx";
import { MoralisProvider } from "react-moralis";
/* -------------------------------
Setup Moralis server
---------------------------------*/
const APP_ID = import.meta.env.VITE_REACT_APP_MORALIS_APPLICATION_ID;
const SERVER_URL = import.meta.env.VITE_REACT_APP_MORALIS_SERVER_URL;
const Application = () => {
if (!APP_ID || !SERVER_URL) {
throw new Error(
"Missing Moralis Application ID or Server URL. Make sure to set your .env file."
);
}
return (
<MoralisProvider appId={APP_ID} serverUrl={SERVER_URL}>
<BrowserRouter>
<App />
</BrowserRouter>
</MoralisProvider>
);
};
ReactDOM.render(
<React.StrictMode>
<Application />
</React.StrictMode>,
document.getElementById("root")
)
Indeed, no real issue, but I must admit it's annoying to see this error every time I reload my page.
New Bug Report
Checklist
Issue Description
Hello,
I have a simple create-react-app that use React Router. As soon as I use a react-moralis hook, I have a "React state update on an unmounted component" error. (see full error below) This error happens only on the first loading and with hard refresh.
Here is my simple component with a react-moralis hook:
And here is my App.js
I do not have this error if I remove the React router and directly call my
HomePage
component. But as this React router is basic and stateless, I don't think that's where the problem come from. I have check react-moralis source code and saw that you never use clean-up function in your useEffect, maybe this is the issue?Environment
Client
1.3.1
1.3.1
MacOS
Logs