From d244c909be59381867d4ae89c56dc68e90a9bc69 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 4 Nov 2024 15:16:14 +0100 Subject: [PATCH] fix bugs --- .../src/app/components/popup-panel.tsx | 6 +-- .../src/lib/components/PluginViewWrapper.tsx | 37 +++++++++++-------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/apps/remix-ide/src/app/components/popup-panel.tsx b/apps/remix-ide/src/app/components/popup-panel.tsx index 363d89d2cf..b85c3eb8a8 100644 --- a/apps/remix-ide/src/app/components/popup-panel.tsx +++ b/apps/remix-ide/src/app/components/popup-panel.tsx @@ -80,14 +80,14 @@ export class PopupPanel extends AbstractPanel { render() { return ( - + ) } - updateComponent(state: popupPanelState & Partial) { + updateComponent(state: popupPanelState, appState: Partial) { return (
{ +export const PluginViewWrapper = ({ plugin, useAppContext = false }: IPluginViewWrapperProps) => { const [state, setState] = useState(null) - const appContext = useContext(AppContext) + const appContext = useAppContext ? useContext(AppContext) : null useEffect(() => { - if (props.plugin.setDispatch) { - props.plugin.setDispatch(setState) + if (plugin.setDispatch) { + plugin.setDispatch(setState) } - if (props.plugin.setAppStateDispatch) { - props.plugin.setAppStateDispatch(appContext.appStateDispatch) + if (useAppContext && appContext.appStateDispatch && plugin.setAppStateDispatch) { + plugin.setAppStateDispatch(appContext.appStateDispatch) } - }, []) + }, [plugin]) - return <>{state ? <>{props.plugin.updateComponent( - { - ...state, - ...appContext['appState'] - })} - : <>} + if (useAppContext && appContext && appContext.appState) { + return ( + <> + {state ? <>{plugin.updateComponent(state, appContext.appState)} : <>} + + ) + } + + return ( + <> + {state ? <>{plugin.updateComponent(state)} : <>} + + ) }