Giter Site home page Giter Site logo

React Native implementation about blurhash HOT 15 CLOSED

woltapp avatar woltapp commented on June 25, 2024 4
React Native implementation

from blurhash.

Comments (15)

mrousavy avatar mrousavy commented on June 25, 2024 6

I did it. It's working on Android and iOS. Uses the lightweight native Image components, and no dependencies. I've also added an encoder so you can encode straight out of your react native app. For decoding, I also added an asynchronous decoder (decodeAsync={true}) so the UI thread never gets blocked.

Here's the link: https://github.com/mrousavy/react-native-blurhash
Or npm: https://www.npmjs.com/package/react-native-blurhash

@woltapp do you want to mention this library in the README in case anyone else is searching for a React Native implementation?

from blurhash.

mrousavy avatar mrousavy commented on June 25, 2024 3

@siddhatiwari while the expo library works, you should keep in mind that the performance is not as good as my native module, since it uses the JS thread for decoding, which is slower and blocks any other JS code execution. @schiller-manuel did an awesome job implementing this without native code, but it's just limited performance wise per design. Always choose the right tool for the job.

from blurhash.

schiller-manuel avatar schiller-manuel commented on June 25, 2024 1

@siddhatiwari you can use gl-react-blurhash in Expo if this is what you want to do.

from blurhash.

espipj avatar espipj commented on June 25, 2024

I'm happy to help with this, I've been trying by using react-native-canvas but it is not performant at all...
It would be amazing a decodeToBase64 method, it would be quite easy from there to give support for React Native... 📱
Another approach would be calling the native libs (Kotlin and Swift) I guess that would be more performant...

from blurhash.

mrousavy avatar mrousavy commented on June 25, 2024

@espipj yes, I've thought about using the native APIs aswell by implementing this extra initializing method in the existing, already very fast, fast-image component library. I've also created an issue over there

Unfortunately I don't have the time right now to create such a pull request, from what I understood though it doesn't seem that hard when I looked into the native code of fast-image.

from blurhash.

espipj avatar espipj commented on June 25, 2024

Hey @mrousavy I got something working on iOS using the swift implementation and linking it to React Native
Screenshot 2020-05-13 at 23 56 31
I'm working on it at https://github.com/espipj/react-native-blurhash
I might need some help as my Swift and Kotlin experience is none
cc/ @LuisRodriguezLD

from blurhash.

schiller-manuel avatar schiller-manuel commented on June 25, 2024

@mrousavy I implemented blurhash using OpenGL so that it can be used in React Native.
The package is available here: https://github.com/schiller-manuel/gl-react-blurhash

from blurhash.

mrousavy avatar mrousavy commented on June 25, 2024

@schiller-manuel that looks really interesting! your idea of using this would be to render this GL View as a placeholder until the image (which is a separate, invisible component) has been loaded, to then swap the GL View with the Image view, correct?

from blurhash.

schiller-manuel avatar schiller-manuel commented on June 25, 2024

yes, that's how I'd use it. In the linked example the onPress event triggers the swapping of placeholder and image, but it could also be the onLoad event of the actual image.

from blurhash.

mrousavy avatar mrousavy commented on June 25, 2024

@espipj @schiller-manuel I've just created a native UI module for this. See: https://github.com/mrousavy/react-native-blurhash.

Currently, I've only implemented iOS, working on Android right now. It uses the default Image component, I still need to create extra properties like resizeMethod, resizeMode, and maybe borderRadius. If you could help me out on that and create some PRs, I'd gladly accept them.

In short: It's a lightweight component that just renders the Blurhash Image in react native. No need for react-native-unimodules, gl-react, gl-react-native, buffer, ...

from blurhash.

siddhatiwari avatar siddhatiwari commented on June 25, 2024

Is there a react-native library that doesn't require native linking?

from blurhash.

siddhatiwari avatar siddhatiwari commented on June 25, 2024

@mrousavy @schiller-manuel Thanks for the quick response! Will check out gl-react-blurhash.

from blurhash.

jerry-git avatar jerry-git commented on June 25, 2024

@woltapp do you want to mention this library in the README in case anyone else is searching for a React Native implementation?

Hi @mrousavy! Firstly, sorry for the super late reply. Secondly, yes let's have it documented in the readme. Would you mind providing a PR for that? 🙂

from blurhash.

mrousavy avatar mrousavy commented on June 25, 2024

@jerry-git sure, here you go: #176

from blurhash.

Thisen avatar Thisen commented on June 25, 2024

Closing, as this is now third-party :)

from blurhash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.