useImage React hook
See original GitHub issueI am thinking to implement useImage
hook with the simple API:
import React from 'react';
import { Image, useImage } from 'react-konva';
export default function App() {
const url = 'some-image-url';
const image = useImage(url);
// it will be undefined while image is loading
// and it will be instance of window.Image when it is loaded
return (
<Stage width={300} heihgt={300}>
<Layer>
<Image image={image} />
</Layer>
</Stage>
);
}
That hook will simplify current image usage https://konvajs.github.io/docs/react/Images.html
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
konvajs/use-image: Custom React Hook for loading images
Custom React Hook for loading images. It loads passed url and creates DOM image with such src . Useful for canvas application like...
Read more >use-image
Custom React Hook for loading images.. Latest version: 1.1.0, ... Start using use-image in your project by running `npm i use-image`.
Read more >useImageOnLoad() react hook
A simple React Hook that helps you improve UX while images are loading. Rather than having an image that "unfolds" from top to...
Read more >Rendering images smoothly using React Hooks
In this article I'm going to create very simple Hook to render images smoothly on the screen (Not really rendering but sort of...
Read more >Use-image NPM
useImage React Hook. Custom React Hook for loading images. It loads passed url and creates DOM image with such src . Useful for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Why don’t implement a better
Image
component for that? I use the following code in my application.https://github.com/konvajs/use-image