Giter Club home page Giter Club logo

Comments (5)

gre avatar gre commented on August 31, 2024

I'm not sure what you mean by "without passing a refer" ?

Can you tell me what would be the signature of such a function? Currently it's basically (ref: ReactRefObject) => Promise<string>

from react-native-view-shot.

FlaviooLima avatar FlaviooLima commented on August 31, 2024

For example passing the component it self like:
<View style={{flex:1, backgroundColor:'red'}} />

from react-native-view-shot.

gre avatar gre commented on August 31, 2024

so basically you want

(elementAkaJSX: React.Element) => Promise<string>

?

I don't think we can make it more optimized than rendering once, getting a ref, and rasterizing it, because <View /> is something that only exist on JS side and will have to be resolved on this side. It will trigger some 'native element' creation through bridge, and only when that is done, we can call the native code to snapshot that..

related to that question, see my answer here: #31 (comment)

maybe more thoughts need to be given into this to provide an elegant API, but I don't think we'll be able to do more efficient things. That said, if you need to render 60 different views, you might want to try to parallelize this work (render all in once, OR maybe 10 at a time. I guess you need to try and see what is the best perfs)

BTW, the react-native-view-shot implementation already should happen asynchronously and should not take time on the UI thread. if it does, it's probably a bug. However, this is probably not true for Android according so this PR: #28 . unfortunately I had to close this PR because the code was not working when I tested, PR is welcomed to fix that state

from react-native-view-shot.

FlaviooLima avatar FlaviooLima commented on August 31, 2024

Yes, my thought was to pass the "component" to native side, see what function react native use to create component in the native side and use it.

My problem is not the react-native-view-shot, it's the need to render the view to use it.
As you said above i will try with just one render create all the Views and take the snapshot's :)
(Fingers cross xD)

I believe we can close this now :)

from react-native-view-shot.

gre avatar gre commented on August 31, 2024

I don't think there is a difference between "passing component to native side, create component and use it" and "rendering the view".

you need to render the view to rasterize it. the only different might be to not actually "showing it to screen" but I don't think there are big perf issue with or without doing that. (maybe i'm wrong?)

thanks

from react-native-view-shot.

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.