Skip to content

Commit

Permalink
feat: delete _EXPERIMENTAL_memoContext props (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoncool authored Nov 16, 2022
1 parent 55c4d96 commit c9d6b64
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 274 deletions.
2 changes: 0 additions & 2 deletions src/components/DashKit/DashKit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ interface DashKitDefaultProps {
noOverlay?: boolean;
draggableHandleClassName?: string;
_EXPERIMENTAL_preventDoubleCompact?: boolean;
_EXPERIMENTAL_memoContext?: boolean;
}

export interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaultProps> {}
Expand All @@ -55,7 +54,6 @@ export class DashKit extends React.PureComponent<DashKitInnerProps> {
},
context: {},
noOverlay: false,
_EXPERIMENTAL_memoContext: false,
};

static registerPlugins(...plugins: Plugin[]) {
Expand Down
3 changes: 0 additions & 3 deletions src/components/DashKit/__stories__/DashKitShowcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type DashKitDemoState = {
customControlsActionData: number;
showCustomMenu: boolean;
_EXPERIMENTAL_preventDoubleCompact: boolean;
_EXPERIMENTAL_memoContext: boolean;
};

export class DashKitShowcase extends React.Component<{}, DashKitDemoState> {
Expand All @@ -41,7 +40,6 @@ export class DashKitShowcase extends React.Component<{}, DashKitDemoState> {
customControlsActionData: 0,
showCustomMenu: true,
_EXPERIMENTAL_preventDoubleCompact: false,
_EXPERIMENTAL_memoContext: false,
};

private dashKitRef = React.createRef<DashKit>();
Expand Down Expand Up @@ -138,7 +136,6 @@ export class DashKitShowcase extends React.Component<{}, DashKitDemoState> {
_EXPERIMENTAL_preventDoubleCompact={
this.state._EXPERIMENTAL_preventDoubleCompact
}
_EXPERIMENTAL_memoContext={this.state._EXPERIMENTAL_memoContext}
/>
</Demo.Row>
</Demo>
Expand Down
10 changes: 2 additions & 8 deletions src/components/DashKitView/DashKitView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import block from 'bem-cn-lite';
import {DashKitContext} from '../../context/DashKitContext';
import GridLayout from '../GridLayout/GridLayout';
import MobileLayout from '../MobileLayout/MobileLayout';
import {withContext, withMemoContext} from '../../hocs/withContext';
import {withContext} from '../../hocs/withContext';
import {useCalcPropsLayout} from '../../hooks/useCalcLayout';

import './DashKitView.scss';
Expand All @@ -25,16 +25,10 @@ function DashKitView(props) {
}

const DashKitViewWithContext = withContext(DashKitView);
const DashKitViewWithMemoContext = withMemoContext(DashKitView);

const DashKitViewForwardedMeta = React.forwardRef((props, ref) => {
const layout = useCalcPropsLayout(props.config, props.registerManager);

return props._EXPERIMENTAL_memoContext ? (
<DashKitViewWithMemoContext {...props} layout={layout} forwardedMetaRef={ref} />
) : (
<DashKitViewWithContext {...props} layout={layout} forwardedMetaRef={ref} />
);
return <DashKitViewWithContext {...props} layout={layout} forwardedMetaRef={ref} />;
});

DashKitViewForwardedMeta.displayName = 'DashKitViewForwardedMeta';
Expand Down
7 changes: 3 additions & 4 deletions src/components/GridLayout/GridLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class GridLayout extends React.PureComponent {
};

adjustWidgetLayout = ({widgetId, needSetDefault, adjustedWidgetLayout}) => {
const {getLayout, memorizeOriginalLayout, revertToOriginalLayout} = this.context;
const {layout, memorizeOriginalLayout, revertToOriginalLayout} = this.context;

if (needSetDefault) {
revertToOriginalLayout(widgetId);
Expand All @@ -53,7 +53,6 @@ export default class GridLayout extends React.PureComponent {
return;
}

const layout = getLayout();
const correspondedLayoutItemIndex = layout.findIndex(
(layoutItem) => layoutItem.i === widgetId,
);
Expand Down Expand Up @@ -106,10 +105,10 @@ export default class GridLayout extends React.PureComponent {
};

render() {
const {getLayout, config, registerManager, editMode, noOverlay, draggableHandleClassName} =
const {layout, config, registerManager, editMode, noOverlay, draggableHandleClassName} =
this.context;
this.pluginsRefs.length = config.items.length;
const layout = getLayout();

return (
<Layout
{...registerManager.gridLayout}
Expand Down
4 changes: 2 additions & 2 deletions src/components/MobileLayout/MobileLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class MobileLayout extends React.PureComponent {
};

render() {
const {config, getLayout} = this.context;
const {config, layout} = this.context;

this.pluginsRefs.length = config.items.length;

Expand All @@ -68,7 +68,7 @@ export default class MobileLayout extends React.PureComponent {
<Item
id={item.id}
item={item}
layout={getLayout()}
layout={layout}
shouldItemUpdate={false}
adjustWidgetLayout={this.adjustWidgetLayout.bind(this, index)}
forwardedPluginRef={(pluginRef) => {
Expand Down
Loading

0 comments on commit c9d6b64

Please sign in to comment.