diff --git a/packages/vscode-extension/src/webview/providers/AlertProvider.tsx b/packages/vscode-extension/src/webview/providers/AlertProvider.tsx index c32f06615..1e0d2bf13 100644 --- a/packages/vscode-extension/src/webview/providers/AlertProvider.tsx +++ b/packages/vscode-extension/src/webview/providers/AlertProvider.tsx @@ -1,4 +1,4 @@ -import React, { createContext, useCallback, useEffect, useState } from "react"; +import React, { createContext, useCallback, useEffect, useMemo, useState } from "react"; import Alert from "../components/shared/Alert"; interface AlertType { @@ -46,8 +46,12 @@ export default function AlertProvider({ children }: { children: React.ReactNode const topAlert = getTopAlert(alerts); + const contextValue = useMemo(() => { + return { openAlert, isOpen, closeAlert }; + }, [openAlert, isOpen, closeAlert]); + return ( - + {children} { + return { + dependencies: depsState, + runDiagnostics, + errors: getErrors(depsState), + }; + }, [depsState, runDiagnostics, getErrors]); + return ( - - {children} - + {children} ); } diff --git a/packages/vscode-extension/src/webview/providers/DevicesProvider.tsx b/packages/vscode-extension/src/webview/providers/DevicesProvider.tsx index f5064779c..5d038dacb 100644 --- a/packages/vscode-extension/src/webview/providers/DevicesProvider.tsx +++ b/packages/vscode-extension/src/webview/providers/DevicesProvider.tsx @@ -5,6 +5,7 @@ import { useState, useEffect, useCallback, + useMemo, } from "react"; import { makeProxy } from "../utilities/rpc"; import { @@ -64,19 +65,18 @@ export default function DevicesProvider({ children }: PropsWithChildren) { }; }, []); - return ( - - {children} - - ); + const contextValue = useMemo(() => { + return { + devices, + finishedInitialLoad, + androidImages, + iOSRuntimes, + reload, + deviceManager: DeviceManager, + }; + }, [devices, finishedInitialLoad, androidImages, iOSRuntimes, reload, DeviceManager]); + + return {children}; } export function useDevices() { diff --git a/packages/vscode-extension/src/webview/providers/LaunchConfigProvider.tsx b/packages/vscode-extension/src/webview/providers/LaunchConfigProvider.tsx index acd0192b9..f2a5c7639 100644 --- a/packages/vscode-extension/src/webview/providers/LaunchConfigProvider.tsx +++ b/packages/vscode-extension/src/webview/providers/LaunchConfigProvider.tsx @@ -5,6 +5,7 @@ import { useState, useEffect, useCallback, + useMemo, } from "react"; import { makeProxy } from "../utilities/rpc"; import { @@ -57,10 +58,12 @@ export default function LaunchConfigProvider({ children }: PropsWithChildren) { [config, setConfig] ); + const contextValue = useMemo(() => { + return { ...config, update, xcodeSchemes }; + }, [config, update, xcodeSchemes]); + return ( - - {children} - + {children} ); } diff --git a/packages/vscode-extension/src/webview/providers/ProjectProvider.tsx b/packages/vscode-extension/src/webview/providers/ProjectProvider.tsx index 3d20ad7ba..d001f3568 100644 --- a/packages/vscode-extension/src/webview/providers/ProjectProvider.tsx +++ b/packages/vscode-extension/src/webview/providers/ProjectProvider.tsx @@ -1,4 +1,4 @@ -import { PropsWithChildren, useContext, createContext, useState, useEffect } from "react"; +import { PropsWithChildren, useContext, createContext, useState, useEffect, useMemo } from "react"; import { makeProxy } from "../utilities/rpc"; import { DeviceSettings, ProjectInterface, ProjectState } from "../../common/Project"; @@ -61,11 +61,11 @@ export default function ProjectProvider({ children }: PropsWithChildren) { }; }, []); - return ( - - {children} - - ); + const contextValue = useMemo(() => { + return { projectState, deviceSettings, project, hasActiveLicense }; + }, [projectState, deviceSettings, project, hasActiveLicense]); + + return {children}; } export function useProject() { diff --git a/packages/vscode-extension/src/webview/providers/WorkspaceConfigProvider.tsx b/packages/vscode-extension/src/webview/providers/WorkspaceConfigProvider.tsx index d6098ba34..a27f2c47e 100644 --- a/packages/vscode-extension/src/webview/providers/WorkspaceConfigProvider.tsx +++ b/packages/vscode-extension/src/webview/providers/WorkspaceConfigProvider.tsx @@ -5,6 +5,7 @@ import { useState, useEffect, useCallback, + useMemo, } from "react"; import { makeProxy } from "../utilities/rpc"; import { WorkspaceConfig, WorkspaceConfigProps } from "../../common/WorkspaceConfig"; @@ -49,8 +50,12 @@ export default function WorkspaceConfigProvider({ children }: PropsWithChildren) [config, setConfig] ); + const contextValue = useMemo(() => { + return { ...config, update }; + }, [config, update]); + return ( - + {children} );