react-file-viewer icon indicating copy to clipboard operation
react-file-viewer copied to clipboard

FileViewer does not change on docx switch

Open djh329 opened this issue 7 years ago • 2 comments

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

djh329 avatar Apr 02 '18 19:04 djh329

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

friscote avatar Dec 22 '19 23:12 friscote

Change an empty file first like

  this.setState(
    {
      //先加载个空附件,来解决相同附件切换的bug
      viewerFileType: 'test',
      viewerFileUrl: '/',
    },
    () => {
      this.setState({
        viewerFileType: file.type,
        viewerFileUrl: file.url,
      });
    },
  )

jazzychai avatar Jun 23 '21 07:06 jazzychai