- Notifications
You must be signed in to change notification settings - Fork1.1k
Closed
Description
In theCreateFileDialog component, we appear to have mutation happening on thesetFileTree setter.
| setFileTree((fileTree)=>createFile(path,fileTree,"")); |
We can see the mutation happening in thecreateFile function withset from lodash.
coder/site/src/utils/filetree.ts
Line 23 inb890930
| returnset(fileTree,path.split("/"),value); |
My understanding is that you aren't supposed to perform mutation on a React state value, so in Strict mode it'll call this function twice to see if you're violating this contract. As we're violating this contract, it gets called twice, and on that second invocationfileTree will contain the new file, and throw an error because the file already exists.