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)} : <>} + + ) }