Skip to content

Commit

Permalink
fix: provide more detailed warning message for <PrismicImage>'s `al…
Browse files Browse the repository at this point in the history
…t`, `fallbackAlt`, `width`, and `pixelDensities` props
  • Loading branch information
angeloashmore committed Apr 15, 2022
1 parent 92303a0 commit 4eaf529
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/PrismicImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,23 @@ const _PrismicImage = (
if (!__PRODUCTION__) {
if (typeof alt === "string" && props.alt !== "") {
console.warn(
`[PrismicImage] The alt prop can only be used to declare an image as decorative by passing an empty string (alt=""). For more details, see ${devMsg(
`[PrismicImage] The "alt" prop can only be used to declare an image as decorative by passing an empty string (alt="") but was provided a non-empty string. You can resolve this warning by removing the "alt" prop or changing it to alt="". For more details, see ${devMsg(
"alt-must-be-an-empty-string",
)}`,
);
}

if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
console.warn(
`[PrismicImage] The fallbackAlt prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=""). For more details, see ${devMsg(
`[PrismicImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${devMsg(
"alt-must-be-an-empty-string",
)}`,
);
}

if (widths && pixelDensities) {
console.warn(
`[PrismicImage] Only one of "widths" or "pixelDensities" props can be provided. "widths" will be used in this case.`,
`[PrismicImage] Only one of "widths" or "pixelDensities" props can be provided. You can resolve this warning by removing either the "widths" or "pixelDensities" prop. "widths" will be used in this case.`,
);
}
}
Expand Down

0 comments on commit 4eaf529

Please sign in to comment.