Description
In my use case, I have it so that when a file is deleted, it first shows a modal that says where the files are used. Upon clicking confirm, it will then call end endpoint to update references to said files and then delete the main file. After the endpoint completes successfully, I have the frontend re-fetch the new data (partially because I couldn't figure out how to update the internal SVAR filemanager state on the frontend) into the same state variable the Filemanager was initialized with (see code reproduction example). Upon doing so, the browser seems to crash "Cannot read properties of undefined (reading 'type')"
The way I've implemented it goes as follows:
- Use api.intercept("delete-files",...) to open the modal and
return false to prevent default action
- Modal calls some endpoints and eventually deletes the file
- On success it re-fetches the data that's used for the
data attribute for the Filemanager component
Code reproduction
I simplified a lot here. Goal is to demonstrate how re-fetching the data (after deleting an item) seems to cause the browser to crash.
https://snippet.svar.dev/react/uxI4MD2Q7
Full error message here:
Cannot read properties of undefined (reading 'type')
at eval (https://codesandbox.svar.dev/node_modules/
svar-ui/filemanager-store/dist/index.js:529:16
at k (https://codesandbox.svar.dev/node_modules/
svar-ui/filemanager-store/dist/index.js:528:13
at Object.exec (https://codesandbox.svar.dev/node_modules/
svar-ui/filemanager-store/dist/index.js:785:17
at T._execNext (https://codesandbox.svar.dev/node_modules/
svar-ui/filemanager-store/dist/index.js:375:35
at T._triggerUpdates (https://codesandbox.svar.dev/node_modules/
svar-ui/filemanager-store/dist/index.js:359:17
at T.setState (https://codesandbox.svar.dev/node_modules/
svar-ui/filemanager-store/dist/index.js:338:19
at T.init (https://codesandbox.svar.dev/node_modules/
svar-ui/filemanager-store/dist/index.js:310:110
at U.init (https://codesandbox.svar.dev/node_modules/
svar-ui/filemanager-store/dist/index.js:1100:20
at eval (https://codesandbox.svar.dev/node_modules/
svar-ui/react-filemanager/dist/index.es.js:1762:9
Object.react_stack_bottom_frame
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:25989:20
runWithFiberInDEV
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:871:30
commitHookEffectListMount
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:13249:29
commitHookPassiveMountEffects
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:13336:11
commitPassiveMountOnFiber
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15484:13
recursivelyTraversePassiveMountEffects
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15439:11
commitPassiveMountOnFiber
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15718:11
recursivelyTraversePassiveMountEffects
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15439:11
commitPassiveMountOnFiber
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15718:11
recursivelyTraversePassiveMountEffects
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15439:11
commitPassiveMountOnFiber
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15476:11
recursivelyTraversePassiveMountEffects
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15439:11
commitPassiveMountOnFiber
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15476:11
recursivelyTraversePassiveMountEffects
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15439:11
commitPassiveMountOnFiber
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15476:11
recursivelyTraversePassiveMountEffects
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15439:11
commitPassiveMountOnFiber
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15718:11
recursivelyTraversePassiveMountEffects
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15439:11
commitPassiveMountOnFiber
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:15519:11
flushPassiveEffects
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:18432:9
eval
https://codesandbox.svar.dev/node_modules/react-dom/cjs/react-dom-client.development.js:17923:15
MessagePort.performWorkUntilDeadline
https://codesandbox.svar.dev/node_modules/scheduler/cjs/scheduler.development.js:45:48
Description
In my use case, I have it so that when a file is deleted, it first shows a modal that says where the files are used. Upon clicking confirm, it will then call end endpoint to update references to said files and then delete the main file. After the endpoint completes successfully, I have the frontend re-fetch the new data (partially because I couldn't figure out how to update the internal SVAR filemanager state on the frontend) into the same state variable the Filemanager was initialized with (see code reproduction example). Upon doing so, the browser seems to crash "Cannot read properties of undefined (reading 'type')"
The way I've implemented it goes as follows:
return falseto prevent default actiondataattribute for the Filemanager componentCode reproduction
I simplified a lot here. Goal is to demonstrate how re-fetching the data (after deleting an item) seems to cause the browser to crash.
https://snippet.svar.dev/react/uxI4MD2Q7
Full error message here: