Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 26, 2021 10:55 am GMT

You might need this React Component

I had this idea when I wanted to create elements based on what their type was but I didn't want to deal with everything that was happening in the background.

I thought I might not be the only one who has this kind of issue so I created this package!

Quick and Easy example

import AsyncoLoad from "asyncoload";const App = () => {    return (        <AsyncoLoad                height="300"                className="something"                src="https://miro.medium.com/max/1200/1*mk1-6aYaf_Bes1E3Imhc0A.jpeg"         />}
Enter fullscreen mode Exit fullscreen mode

This will return an <img ... /> tag because the specified URL contains and image.

How does this work?

When you're passing the src prop, the component will make an asynchronous request with Axios to the URL specified and will return you the image in this case.

What content can I load with this?

For now you can load images, videos and audio

Is it available on NPM or Yarn registry

Now it's not because I messed up some stuff and I'll be able to publish it only after 24 hours

GitHub Link?

Sure https://github.com/MichaelGrigoryan25/asyncoload/


Original Link: https://dev.to/michaelgrigoryan25/you-might-need-this-react-component-1dca

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To