Video displayed in ReactJS component not updating

前端 未结 5 1399

I\'m new to ReactJS (0.13.1), and I\'ve created a component in my app to display HTML5 video.

It seems to work perfectly but only for the first selection. The vid

5条回答
  •  悲哀的现实
    2020-12-18 23:19

    I faced the same issue and I didn't have access to the HTML tag as I was using a library to render the video (not the native HTML tag) which is internally responsible for rendering the tag.

    In this case I have found another solution which I think is better to solve the same issue.

    Before:

    
    

    After:

    
      
    
    

    Or this if you're using the native HTML tag:

    
      
    

    This way React will render different video tags because the src prop will be different hence rendering a different HTML tag each time to avoid this issue.

    I find this way cleaner and simpler and will work in both cases if you have or don't have access to the HTML tag.

提交回复
热议问题