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: throw when `<PrismicLink>`'s `field` or `document` prop value is missing required properties #153

Closed angeloashmore closed 1 year ago

angeloashmore commented 1 year ago

Types of changes

Description

This PR adds a development-only error handler to the <PrismicLink> component.

When <PrismicLink> receives a field or document prop value with missing required properties, an error is thrown with a helpful message. It also logs the invalid prop value to the console before throwing for easier debugging.

See the full message in messages/missing-link-properties.md.

For more details, see #150.

Checklist:

🦉

codecov-commenter commented 1 year ago

Codecov Report

Merging #153 (949a83d) into master (c21caf0) will increase coverage by 0.00%. The diff coverage is 91.66%.

@@           Coverage Diff           @@
##           master     #153   +/-   ##
=======================================
  Coverage   91.61%   91.61%           
=======================================
  Files          18       18           
  Lines         322      334   +12     
  Branches       77       84    +7     
=======================================
+ Hits          295      306   +11     
  Misses          5        5           
- Partials       22       23    +1     
Impacted Files Coverage Δ
src/PrismicLink.tsx 94.00% <91.66%> (-0.74%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c21caf0...949a83d. Read the comment docs.

github-actions[bot] commented 1 year ago

size-limit report 📦

Path Size
dist/index.js 5.63 KB (+2.86% 🔺)
dist/index.cjs 7.16 KB (+2.35% 🔺)