Since react-imgix uses srcset and sizes, it allows the browser to render the correctly sized image immediately after the page has loaded. React-imgix also works well on the server. Width and height known: If the width and height are known beforehand, it is recommended that they are set explicitly: import Imgix from "react-imgix" All of this information has been placed into the srcset and sizes attributes. Since imgix can generate as many derivative resolutions as needed, react-imgix calculates them programmatically, using the dimensions you specify. This will generate HTML similar to the following:
#SIMPLEIMAGE HAS NO ATTRIBUTE READ HOW TO#
Eric Portis' "Srcset and sizes" article goes into depth on how to use the sizes attribute.
If your image is not full-bleed, you should use a different value for sizes. Please note: 100vw is an appropriate sizes value for a full-bleed image. in react component Examples Basic Use Caseįor simply using as you would use an, react-imgix can be used as follows: import Imgix from "react-imgix" If you are not using ES6 modules, you don't have to do anything Usage import Imgix from "react-imgix" If a ES6-module-aware bundler is being used to consume this module, it will pick up an ES6 module version and can perform tree-shaking. This module exports two transpiled versions. A look into how imgix can work with srcset and sizes to serve the right image.