Compare commits

..

No commits in common. "v0.1.0-develop.16" and "v0.1.0-develop.15" have entirely different histories.

4 changed files with 14 additions and 25 deletions

View File

@ -1,10 +1,3 @@
# [0.1.0-develop.16](https://git.lumeweb.com/LumeWeb/sdk/compare/v0.1.0-develop.15...v0.1.0-develop.16) (2023-10-12)
### Bug Fixes
* try to avoid unneeded re-rendering if we unmount while in the process of mounting ([92c18ca](https://git.lumeweb.com/LumeWeb/sdk/commit/92c18ca940b3d8651064d58600fdcf83298b305d))
# [0.1.0-develop.15](https://git.lumeweb.com/LumeWeb/sdk/compare/v0.1.0-develop.14...v0.1.0-develop.15) (2023-10-12)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@lumeweb/sdk",
"version": "0.1.0-develop.16",
"version": "0.1.0-develop.15",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@lumeweb/sdk",
"version": "0.1.0-develop.16",
"version": "0.1.0-develop.15",
"dependencies": {
"@lumeweb/kernel-network-registry-client": "0.1.0-develop.10",
"@lumeweb/libkernel": "0.1.0-develop.65",

View File

@ -1,6 +1,6 @@
{
"name": "@lumeweb/sdk",
"version": "0.1.0-develop.16",
"version": "0.1.0-develop.15",
"type": "module",
"main": "lib/index.js",
"types": "lib/src/index.d.ts",

View File

@ -43,10 +43,9 @@ const LumeContext = createContext<LumeContextType | undefined>(undefined);
const LumeProvider = ({ children }) => {
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [ready, setReady] = useState<boolean>(false);
const [ready, setReady] = useState(false);
const [lume, setLume] = useState<LumeObject>({ networks: [] });
const statusUnsubs = useRef(new Map());
const isMounted = useRef(true); // Use a ref to track mounting
const handleStatusUpdate = useCallback((id, newNetwork) => {
setLume((prevLume) => {
@ -65,6 +64,7 @@ const LumeProvider = ({ children }) => {
for (const type of types) {
const list = await networkRegistry.getNetworksByType(type);
for (const module of list) {
const client = createNetworkClient(module);
const name = await client.name();
@ -96,29 +96,25 @@ const LumeProvider = ({ children }) => {
statusUnsubs.current.forEach((unsub) => unsub());
statusUnsubs.current = newStatusUnsubs;
if (isMounted.current) {
setLume((prevLume) => ({
...prevLume,
networks: Array.from(newNetworksMap.values()),
}));
}
setLume((prevLume) => ({
...prevLume,
networks: Array.from(newNetworksMap.values()),
}));
} catch (error) {
if (isMounted.current) {
console.error("Error fetching and updating networks:", error);
}
console.error("Error fetching and updating networks:", error);
}
};
useEffect(() => {
fetchAndUpdateNetworks();
loginComplete().then(() => isMounted.current && setIsLoggedIn(true));
init().then(() => isMounted.current && setReady(true));
loginComplete().then(() => setIsLoggedIn(true));
init().then(() => setReady(true));
const subDone = networkRegistry.subscribeToUpdates(fetchAndUpdateNetworks);
return () => {
isMounted.current = false; // Track component unmounting
subDone?.();
subDone();
statusUnsubs.current.forEach((unsub) => unsub());
};
}, [fetchAndUpdateNetworks]);