pmndrs / use-asset Goto Github PK
View Code? Open in Web Editor NEW๐ฆ A promise caching strategy for React Suspense
๐ฆ A promise caching strategy for React Suspense
Some frameworks like Next performs data prefetching in the server-side, providing the initial data for the whole app. Libraries like swr
and react-query
takes advantage of this by using the prefetched data as the initial cache data and performs the fetch process/cache invalidation only on client-side.
Asset hydration helps because React SSR cannot handle nor does not support Suspense (CM, however, supports this) and since the asset is guaranteed to have an initial data, the component does not have to suspend during SSR and the potentially suspending component can safely present its success UI.
I think something like asset.hydrate(args, data)
or useAsset(asset, args, initialData)
is a good API. Thoughts?
I'm looking into using react-three-fiber
and use-asset
for one of my projects, and I've noticed that the infinite load example doesn't work on my display. Looking into the code, this condition for triggering fetching may never be true for larger screens:
e.target.scrollTop > content.current.scrollHeight - 1000
It's a very minor thing, but I was wondering if it makes sense to increase this threshold and make it independent of the screen size, e.g. something like:
e.target.scrollTop > content.current.scrollHeight / 2
And thanks very much for all the awesome work on the poimandres familiy of libraries! I really appreciate how you use the most interesting features of React to make sure that all the different use cases stay performant and simple to use. ๐
So that Typescript knows what type of variable is returned from e.g. asset.read()
and you don't have to do something like this when consuming the asset:
const stuff = asset.read( name, ...args ) as StuffType // `as StuffType` should ideally not be necessary
Is there reload api for refresh the asset?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.