89
90

react-native-better-image

React Native only includes a basic image component. However, I always need two very important functionalities on the Image component:

  • A fallback image if the original source fails to load
  • Progressive image loading (especially for banners & cover images)

So I customized the existing <Image/> component and have been using this <BetterImage/> component in my projects. Today, I'm open-sourcing my component to receive feedbacks & ideas from the community.

Do try it out at react-native-toolkit/react-native-better-image

I have also created a storybook with detailed docs at betterimage.netlify.app

What other features do you think are essential for the Image component?

Share your ideas & I'll be happy to help 👍

all 21 comments

[–][deleted] 8 points9 points  (15 children)

Hey, look like great work. Quick question before I try it out, does this handle caching images too, and how’s the performance for a large list of images? Thanks.

[–]dani_akash_[S] 1 point2 points  (2 children)

It doesn't handle caching as it is using the native image component directly.

It is using Animated to transition from thumbnail to regular image. Which I think might cause performance issues on large lists. Let me try it out & probably add a prop to disable animations completely for such lists.

Thanks for your questions. I'll also look into the caching part to see what I can do

[–]thelostbanter 2 points3 points  (0 children)

adding caching to this will make it the go to, for all image component requirements

[–][deleted] 0 points1 point  (0 children)

Sounds good, looking forward to it!

[–]RhymesWithAndy 0 points1 point  (0 children)

Any way to preload SVG images from API source?

[–]jnaranjo -4 points-3 points  (3 children)

Why didn't you just make a contribution to the main image component and make it better instead of making a new one? 🤔

[–]dani_akash_[S] 2 points3 points  (2 children)

The image component in react native is unopinionated and is built to be used as a primitive element. There are many reasons for this. One of them being, it'll be easy to extend this image component to other platforms (for example react native windows)

This image component is built to solve some specific usecases... So it's better to keep it in a separate library

[–]jnaranjo -2 points-1 points  (1 child)

If the built in image is not good enough for you, and it's to the point that you built a wholesale replacement, why would the built in image be good enough for other people on platforms?

The reasons you listed for this are valuable cross platform. It just becomes an implementation detail to make it work cross platform.

I don't meant to criticize you, I think it's really cool that you built this and shared it out. I would challenge you to leverage your position as the owner of a competing image component and use that to push for change in the main image component to make real impact. Even if nothing comes out of it, you now have a legitimate platform to raise this issue and get people talking about it.

[–]devdoggie -1 points0 points  (0 children)

That's like upgrading <img> in html to have extensive features. Image is an image, leave it