An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
January 26, 2021 10:55 am GMT
Original Link: https://dev.to/michaelgrigoryan25/you-might-need-this-react-component-1dca
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?
Original Link: https://dev.to/michaelgrigoryan25/you-might-need-this-react-component-1dca
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To