chatengine-io / react-chat-engine

React component for a cheap and easy chat API
137 stars 35 forks source link

Fix memory leak and closeIcon position. #46

Closed Sergey1888888 closed 3 years ago

Sergey1888888 commented 3 years ago

Memory Leak.

As the documentation says: "Each time you call createObjectURL(), a new object URL is created, even if you've already created one for the same object." https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL URL.createObjectURL(props.file) at src attribute will constantly add new object URL. So I added useEffect which depends on props.files and creates 1 object URL. But this is not the best solution and needs some work. For example, when deleting, clicking on closeIcon will change props.file and useEffect will create another object URL for each remaining file. You will need to add URL.revokeObjectURL().

closeIcon position.

closeIcon position was above attachments and there was no way to remove a single image. It now looks like this: result

alamorre commented 3 years ago

Good stuff! I got some e2e tests that I run and they both pass