react-image-annotate icon indicating copy to clipboard operation
react-image-annotate copied to clipboard

ReactImageAnnotate props don't update with state change

Open nbenhaim opened this issue 5 years ago • 5 comments

Hi, I'm pretty new to react so this is may be something I'm doing wrong on my end, but I wrapped ReactImageAnnotate component in my own component, update the state on a button click callback, and feed the state's values back into image_url and images props - but the UI doesn't update with my new images. I simply got started by doing npm create-react-app and then npm install react-image-annotate

nbenhaim avatar Dec 25 '19 21:12 nbenhaim

I am facing the same problem. Component is rendered properly, consuming local state variable which is empty array at the beginning.

After async loading of images this variable is updated in local state but it looks like ReactImageAnnotate component doesn't update.

I can manually refresh the annotator if there is a way. Any comment on this?

bozazec avatar Mar 04 '20 11:03 bozazec

Sorry for the delay getting back to this- somehow I missed it!

Yes this is a problem, we carefully memoize to optimize the component and it sometimes causes a refreshing bug.

The workaround until this is fixed is to set a key={imageUrl} on the annotator. Whenever the key changes the component will refresh.

Thanks and sorry for the delay!!

seveibar avatar Apr 12 '20 07:04 seveibar

@seveibar could you elaborate more about this fix? I have the same issue when using react-image-annotate tool. I tried to add key={imageUrl} but it failed to load the new local images state!

I am getting the following error: TypeError: Cannot read property 'regions' of undefined

solix avatar Aug 30 '20 17:08 solix

Hey @solix, can you provide a code sandbox? I'm going to be taking a look at this soon and that could speed up the process!

seveibar avatar Aug 30 '20 19:08 seveibar

Hey @seveibar, I could fix the issue by adding images list to key prop like key = {this.state.images}, and then it was fine.

solix avatar Sep 02 '20 17:09 solix