Skip to content

PanelStack2 migration

Adi Dahiya edited this page Feb 24, 2021 · 6 revisions

Requirements

  • <PanelStack2> uses React hooks, so you must use React 16.8+, otherwise it will fail at runtime. @blueprintjs/core >=v3.39.0 <4.0.0 is lenient about its React peer dependency and will not enforce this constraint for you.

Notable changes compared to PanelStack

  • The component type is now constrained by a generic type parameter. This change fixes issues like #4272.
    • As a JavaScript user, this does not affect you.
    • It is unlikely to require any changes for TypeScript consumers either, as the correct types will be inferred across the component API.
  • Interface names have changed.
    • IPanel -> Panel
    • IPanelProps -> PanelActions
  • The Panel<T> interface has changed to use a slightly more standard "render prop" pattern:
import { Panel, PanelActions } from "@blueprintjs/core";

interface PanelExampleProps {
    ...
}

const PanelExample: React.FC<PanelExampleProps & PanelActions<PanelExampleProps> = props => {
    ...
};

const initialPanel: Panel<PanelExampleProps>> = {
    props: {
        panelNumber: 1,
    },
-    component: PanelExample,
+    renderPanel: PanelExample,
+    // or, if it was a class component:
+    renderPanel: p => <PanelExample {...p />,
    title: "Panel 1",
};
Clone this wiki locally