Merge pull request #1641 from YinDongFang/fix/networkservice
Fix redundant instantiation of NetworkService
This commit is contained in:
1 file changed
+4
-3
@@ -1,14 +1,15 @@
|
|||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { useNavigate } from "react-router";
|
import { useNavigate } from "react-router";
|
||||||
import { setNetworkService } from "./NetworkService";
|
import { setNetworkService } from "./NetworkService";
|
||||||
import NetworkService from "./NetworkService";
|
import NetworkService, { networkService } from "./NetworkService";
|
||||||
import { store } from "../store";
|
import { store } from "../store";
|
||||||
|
|
||||||
const NetworkServiceProvider = ({ children }) => {
|
const NetworkServiceProvider = ({ children }) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const networkService = new NetworkService(store, dispatch, navigate);
|
if (!networkService) {
|
||||||
setNetworkService(networkService);
|
setNetworkService(new NetworkService(store, dispatch, navigate));
|
||||||
|
}
|
||||||
return children;
|
return children;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user