Skip to content

Commit 5e1bdf3

Browse files
committed
adjustments from feedback
1 parent 6588aac commit 5e1bdf3

File tree

6 files changed

+20
-46
lines changed

6 files changed

+20
-46
lines changed

dash/dash-renderer/src/actions/callbacks.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import {
3434
CallbackResponseData,
3535
SideUpdateOutput
3636
} from '../types/callbacks';
37-
import {getComponentLayout} from '../wrapper/wrapping';
3837
import {isMultiValued, stringifyId, isMultiOutputProp} from './dependencies';
3938
import {urlBase} from './utils';
4039
import {getCSRFHeader, dispatchError} from '.';
@@ -359,13 +358,10 @@ function updateComponent(component_id: any, props: any, cb: ICallbackPayload) {
359358
// error.
360359
return;
361360
}
362-
const component = getComponentLayout(componentPath, _state);
363361
dispatch(
364362
updateProps({
365363
props,
366364
itempath: componentPath,
367-
component,
368-
config,
369365
renderType: 'callback'
370366
})
371367
);

dash/dash-renderer/src/observers/executedCallbacks.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import {ICallback, IStoredCallback} from '../types/callbacks';
3434

3535
import {updateProps, setPaths, handleAsyncError} from '../actions';
3636
import {getPath, computePaths} from '../actions/paths';
37-
import {getComponentLayout} from '../wrapper/wrapping';
3837

3938
import {applyPersistence, prunePersistence} from '../persistence';
4039
import {IStoreObserverDefinition} from '../StoreObserver';
@@ -47,7 +46,7 @@ const observer: IStoreObserverDefinition<IStoreState> = {
4746

4847
function applyProps(id: any, updatedProps: any) {
4948
const _state = getState();
50-
const {layout, paths, config} = _state;
49+
const {layout, paths} = _state;
5150
const itempath = getPath(paths, id);
5251
if (!itempath) {
5352
return false;
@@ -65,14 +64,11 @@ const observer: IStoreObserverDefinition<IStoreState> = {
6564
// In case the update contains whole components, see if any of
6665
// those components have props to update to persist user edits.
6766
const {props} = applyPersistence({props: updatedProps}, dispatch);
68-
const component = getComponentLayout(itempath, _state);
6967
dispatch(
7068
updateProps({
7169
itempath,
7270
props,
7371
source: 'response',
74-
component,
75-
config,
7672
renderType: 'callback'
7773
})
7874
);

dash/dash-renderer/src/reducers/reducer.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,6 @@ export const apiRequests = [
2727
'loginRequest'
2828
];
2929

30-
function adjustHashes(state, action) {
31-
const actionPath = action.payload.itempath;
32-
const strPath = stringifyPath(actionPath);
33-
const prev = pathOr(0, [strPath, 'hash'], state);
34-
state = assoc(
35-
strPath,
36-
{
37-
hash: prev + 1,
38-
changedProps: action.payload.props,
39-
renderType: action.payload.renderType
40-
},
41-
state
42-
);
43-
return state;
44-
}
45-
4630
const layoutHashes = (state = {}, action) => {
4731
if (
4832
includes(action.type, [
@@ -53,7 +37,18 @@ const layoutHashes = (state = {}, action) => {
5337
) {
5438
// Let us compare the paths sums to get updates without triggering
5539
// render on the parent containers.
56-
return adjustHashes(state, action);
40+
const actionPath = action.payload.itempath;
41+
const strPath = stringifyPath(actionPath);
42+
const prev = pathOr(0, [strPath, 'hash'], state);
43+
state = assoc(
44+
strPath,
45+
{
46+
hash: prev + 1,
47+
changedProps: action.payload.props,
48+
renderType: action.payload.renderType
49+
},
50+
state
51+
);
5752
}
5853
return state;
5954
};

dash/dash-renderer/src/utils/clientsideFunctions.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {updateProps, notifyObservers} from '../actions/index';
22
import {getPath} from '../actions/paths';
33
import {getStores} from './stores';
4-
import {getComponentLayout} from '../wrapper/wrapping';
54

65
/**
76
* Set the props of a dash component by id or path.
@@ -18,19 +17,16 @@ function set_props(
1817
const {dispatch, getState} = ds[y];
1918
let componentPath;
2019
const _state = getState();
21-
const {paths, config} = _state;
20+
const {paths} = _state;
2221
if (!Array.isArray(idOrPath)) {
2322
componentPath = getPath(paths, idOrPath);
2423
} else {
2524
componentPath = idOrPath;
2625
}
27-
const component = getComponentLayout(componentPath, _state);
2826
dispatch(
2927
updateProps({
3028
props,
3129
itempath: componentPath,
32-
component,
33-
config,
3430
renderType: 'clientsideApi'
3531
})
3632
);

dash/dash-renderer/src/wrapper/DashWrapper.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ type MemoizedPropsType = {
6363
function DashWrapper({
6464
componentPath,
6565
_dashprivate_error,
66-
_passedComponent,
67-
_newRender,
66+
_passedComponent, // pass component to the DashWrapper in the event that it is a newRender and there are no layouthashes
67+
_newRender, // this is to force the component to newly render regardless of props (redraw and component as props) is passed from the parent
6868
...extras
6969
}: DashWrapperProps) {
7070
const dispatch = useDispatch();
@@ -84,7 +84,7 @@ function DashWrapper({
8484

8585
/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-vars */
8686
// @ts-ignore
87-
const newlyRendered = useMemo(() => {
87+
const newlyRendered: any = useMemo(() => {
8888
if (_newRender) {
8989
memoizedProps.current = {};
9090
newRender.current = true;
@@ -154,8 +154,6 @@ function DashWrapper({
154154
updateProps({
155155
props: changedProps,
156156
itempath: componentPath,
157-
component,
158-
config,
159157
renderType: 'internal'
160158
})
161159
);
@@ -461,14 +459,12 @@ function DashWrapper({
461459
hydratedChildren = wrapChildrenProp(
462460
componentProps.children,
463461
['children'],
464-
!h || newRender.current || 'children' in changedProps
465-
? {}
466-
: 0
462+
!h || newRender.current || 'children' in changedProps ? {} : 0
467463
);
468464
}
469465
newRender.current = false;
470466

471-
const rendered = config.props_check ? (
467+
return config.props_check ? (
472468
<CheckedComponent
473469
element={element}
474470
props={hydratedProps}
@@ -484,8 +480,6 @@ function DashWrapper({
484480
) : (
485481
createElement(element, hydratedProps, extraProps, hydratedChildren)
486482
);
487-
488-
return rendered;
489483
};
490484

491485
let hydrated = null;

dash/dash-renderer/src/wrapper/wrapping.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ export function checkRenderTypeProp(componentDefinition: any) {
6767
'dashRenderType' in
6868
pathOr(
6969
{},
70-
[
71-
componentDefinition?.namespace,
72-
componentDefinition?.type
73-
],
70+
[componentDefinition?.namespace, componentDefinition?.type],
7471
window as any
7572
)
7673
);

0 commit comments

Comments
 (0)