({
componentPath,
_dashprivate_error,
_passedComponent, // pass component to the DashWrapper in the event that it is a newRender and there are no layouthashes
_newRender, // this is to force the component to newly render regardless of props (redraw and component as props) is passed from the parent
...extras
}: DashWrapperProps)
| 67 | }; |
| 68 | |
| 69 | function DashWrapper({ |
| 70 | componentPath, |
| 71 | _dashprivate_error, |
| 72 | _passedComponent, // pass component to the DashWrapper in the event that it is a newRender and there are no layouthashes |
| 73 | _newRender, // this is to force the component to newly render regardless of props (redraw and component as props) is passed from the parent |
| 74 | ...extras |
| 75 | }: DashWrapperProps) { |
| 76 | const dispatch = useDispatch(); |
| 77 | const memoizedKeys: MutableRefObject<MemoizedKeysType> = useRef({}); |
| 78 | const newRender = useRef(false); |
| 79 | const freshRenders = useRef(0); |
| 80 | const renderedPath = useRef<DashLayoutPath>(componentPath); |
| 81 | let renderComponent: any = null; |
| 82 | let renderComponentProps: any = null; |
| 83 | let renderH: any = null; |
| 84 | |
| 85 | // Get the config for the component as props |
| 86 | const config: DashConfig = useSelector(selectConfig); |
| 87 | |
| 88 | // Select component and it's props, along with render hash, changed props and the reason for render |
| 89 | const [component, componentProps, h, changedProps, renderType] = |
| 90 | useSelector(selectDashProps(componentPath), selectDashPropsEqualityFn); |
| 91 | |
| 92 | renderComponent = component; |
| 93 | renderComponentProps = componentProps; |
| 94 | renderH = h; |
| 95 | |
| 96 | useMemo(() => { |
| 97 | if (_newRender) { |
| 98 | newRender.current = true; |
| 99 | renderH = 0; |
| 100 | freshRenders.current += 1; |
| 101 | if (renderH in memoizedKeys.current) { |
| 102 | delete memoizedKeys.current[renderH]; |
| 103 | } |
| 104 | } else { |
| 105 | newRender.current = false; |
| 106 | } |
| 107 | renderedPath.current = componentPath; |
| 108 | }, [_newRender]); |
| 109 | |
| 110 | const setProps = (newProps: UpdatePropsPayload) => { |
| 111 | const {id} = renderComponentProps; |
| 112 | const {_dash_error, ...restProps} = newProps; |
| 113 | |
| 114 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
| 115 | // @ts-ignore |
| 116 | dispatch((dispatch, getState) => { |
| 117 | const currentState = getState(); |
| 118 | const {graphs} = currentState; |
| 119 | const oldLayout = getComponentLayout( |
| 120 | renderedPath.current, |
| 121 | currentState |
| 122 | ); |
| 123 | if (!oldLayout) return; |
| 124 | const {props: oldProps} = oldLayout; |
| 125 | if (!oldProps) return; |
| 126 | const changedProps = pickBy( |
nothing calls this directly
no test coverage detected
searching dependent graphs…