FileViewer does not change on docx switch
When I have change filePath for two different .docx files, the FileViewer does not update. It does update between different mp3 files, however. This may be a bug with the docx driver.
By console logging the object, I know that the props change, its the view itself that does not update. Moreover, if I go from a docx to a pdf/mp3/other_file_type to a docx, it will work properly
No update? I am facing the same problem. UPD Found a workaround in React.js - force a component to unmount by using a key on a component that wraps FileViewer. See here the full answer - https://stackoverflow.com/a/59449706/4447655
Change an empty file first like
this.setState(
{
//先加载个空附件,来解决相同附件切换的bug
viewerFileType: 'test',
viewerFileUrl: '/',
},
() => {
this.setState({
viewerFileType: file.type,
viewerFileUrl: file.url,
});
},
)