I store the selected file index to local storage using useEffect in the file explorer and then get the index stored in the local storage to get the content from the selected file. This keeps the selected file highlighted and its contents on the screen even if the page refreshes. The file being deleted is managed separately so you can delete a file that isn't currently being displayed without changing the file contents being displayed. The context menu for deleting a file is brought up by right clicking a file and selecting the delete option. If the file currently selected is deleted the displayed content returns to a default state.
I store the selected file index to local storage using useEffect in the file explorer and then get the index stored in the local storage to get the content from the selected file. This keeps the selected file highlighted and its contents on the screen even if the page refreshes. The file being deleted is managed separately so you can delete a file that isn't currently being displayed without changing the file contents being displayed. The context menu for deleting a file is brought up by right clicking a file and selecting the delete option. If the file currently selected is deleted the displayed content returns to a default state.