Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resetting isNoImage on receiving new props #4

Open
readeral opened this issue Apr 3, 2018 · 1 comment
Open

Resetting isNoImage on receiving new props #4

readeral opened this issue Apr 3, 2018 · 1 comment

Comments

@readeral
Copy link

readeral commented Apr 3, 2018

Hi, thanks for this library.

I've been trying to tweak the code so that when a new image src is received, isNoImage is reset to false, before img onError determines its value for the new img src.

I know virtually nothing about Flow, and had assumed I could use React lifecycles to achieve this, but alas, I haven't managed to get it working, either with componentWillReceiveProps or the replacement for it, getDerivedStateFromProps. I'm guessing Flow doesn't respond to lifecycle methods.

Any hints on how to update state on receiving a new url value?

An example of the use case: https://novelroasters.com/gear/able-brewing-aeropress-filter
Selecting (from the drop down) 'Fine' and 'Standard' update my images accordingly. However 'TwinPack' currently has no image associated with it, and so the default noImage url is shown. I would like to be able to click back on a different select option again (Fine/Standard) and have the image update.

Cheers,

Al

@readeral
Copy link
Author

readeral commented Apr 3, 2018

FWIW, the image does update in the code, even if it doesn't display, it's just that isNoImage remains 'True' and so the default image is the one that displays. Using React Tools I can uncheck the box and see that everything else is working perfectly. It's just updating isNoImage that I'm after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant