prismicio / prismic-react

React components and hooks to fetch and present Prismic content
https://prismic.io/docs/technologies/homepage-reactjs
Apache License 2.0
153 stars 40 forks source link

fix: prefer warning over throwing when `<PrismicLink>` is given an invalid prop in development #157

Closed angeloashmore closed 1 year ago

angeloashmore commented 1 year ago

Types of changes

Description

This PR changes <PrismicLink>'s development-only behavior to warn rather than throw when given an invalid Link field or Prismic document (in most cases; see the note below).

In addition to reducing the severity of an invalid field or document, this PR also fixes a bug where a valid unfilled Link field (i.e. a field that a content writer did not fill in) was treated as invalid. Unfilled Link fields are now treated as valid.

Note: <PrismicLink> will still throw if a link_type property is missing from the provided field prop value. link_type is required to detect the type of link and is populated even for unfilled Link fields.

(Thanks to @kb1995 for discovering this bug!)

Checklist:

🐱

github-actions[bot] commented 1 year ago

size-limit report 📦

Path Size
dist/index.js 5.65 KB (+0.4% 🔺)
dist/index.cjs 7.18 KB (+0.31% 🔺)