Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion code/core/src/manager/components/panel/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ const Section = styled.section({
flexDirection: 'column',
});

// Ensures we don't cause difficult-to-debug hooks violations
// whether addon authors pass a React component ctor or anonymous function.
function renderChild(RenderProp: Addon_BaseType['render']) {
return <RenderProp active={true} />;
}

// Avoids crashes due to rules of hooks.
const PreRenderAddons = ({ panels }: { panels: Record<string, Addon_BaseType> }) => {
return Object.entries(panels).map(([k, v]) => (
<StatelessTabPanel key={k} name={k} hasScrollbar={false}>
<TabErrorBoundary key={k}>{v.render({ active: true })}</TabErrorBoundary>
<TabErrorBoundary key={k}>{renderChild(v.render)}</TabErrorBoundary>
</StatelessTabPanel>
));
};
Expand Down