react-img

An <img> element with loading & error behaviors

Usage no npm install needed!

<script type="module">
  import reactImg from 'https://cdn.skypack.dev/react-img';
</script>

README

Summary

React component that adds some niceties to the standard <img> element.

  • Adds an attribute while loading, as a styling hook.
  • Adds an attribute if the src fails to load, as a styling hook.
  • Can use a fallback src if the original fails to load.

Released under the MIT License