react-video-thumbnail
react-video-thumbnail copied to clipboard
(Bug) videoUrl does not get updated on props change
While using VideoThumbnail and changing the videoUrl of using props does not changes videoUrl and same thumbnail gets generated again
@brothatru Could you please look into this and tell me a turnaround as this library is very important for my project
Did you find a solution for this?
Since this bug was making an issue, how i approached this was to use a timer to hide it for 100ms and so that it is forced to rerender. i ll post the code for it below.
const [
forceRerender,
setForceRerender,
] =useState(ZERO)
useEffect(() => {
if (src) {
setForceRerender(ZERO)
const timer = setTimeout(() => {
setForceRerender(forceRerender+ ONE)
}, HUNDRED)
return () => clearTimeout(timer)
}
}, [
src,
])
return (
{ forceRerender > ZERO &&<VideoThumbnail
videoUrl={src}
/>}
)
Where the src is the url incoming from the props. This worked out for me. Good luck! P.S in case the logic can be improved, please do let me know!