question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PrismicLink: Missing Link Properties error message isn't helpful enough

See original GitHub issue

Is your feature request related to a problem? Please describe.

I would like to suggest a feature of making the PrismicLink feedback slightly more verbose message for the Missing Link information message from the CLI.

Currently when there is an error the message is like this:

[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see https://prismic.dev/msg/react/v2.4.2/missing-link-properties { link_type: 'Any' }

First time seeing it, but also I have no idea which link. Especially when there is quite a lot of them…

Describe the solution you’d like

I would like to maybe see the extended information in that object maybe showing the url / uid of the document in the local CLI environment (not sure if these pop up in the browser console.)

Basically: { link_type: 'Any' , uid: 'xyz-uid-for-a-document'} is a lot easier to debug.

Describe alternatives you’ve considered

None.

Additional context

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ReeceMcommented, Jul 27, 2022

Also the Link class is a whole lot better than before 😃 💯

1reaction
angeloashmorecommented, Jul 30, 2022

Hey @ReeceM, it turns out there was a bug in <PrismicLink>! The test to check for the warning on empty links was written incorrectly (probably an accident from copy and pasting part of the test while it was being written).

This means your code is probably correct and it was just an issue within <PrismicLink>.

It should be fixed as of v2.4.4, which you can upgrade to using the following command:

npm install @prismicio/react@latest

If you want to see more details on the fix, you can check out the PR here: #163.

Thanks for finding this issue and reporting it! 🙂


Is that why there is the need to use the isFilled.link() helper?

That’s right; the isFilled.link() helper tells you if a Link field is filled or not. All Link fields, even empty ones, are objects containing at least a link_type property. This means something like slice?.primary?.secondaryLink will always return true, even if the field is empty.

isFilled.link() is used inside <PrismicLink>, so you shouldn’t need to use it manually in your code unless you want to conditionally render content around the link, such as a wrapping <div>.

Let me know if you have any other questions and I’ll try to answer them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React PrismicLink component causing error when not set (on ...
Error: [PrismicLink] The provided field is missing required properties to properly render a link. The link may not render.
Read more >
Preview feature? · Issue #22 · prismicio/prismic-gatsby - GitHub
Is there any way to get Prismic's in-situ preview feature working with a (deployed) Gatsby site?
Read more >
Build Flexible CMS Layouts with Slice Machine
The modern web is modular, and Prismicio's Slice Machine brings block-based editing to the CMS. In this episode, Lucie Haberer will teach us...
Read more >
prismicio/prismic-react Issues - Giters
Provide feedback when a `<PrismicLink>` component receives an invalid value ... PrismicLink: Missing Link Properties error message isn't helpful enough.
Read more >
Missing release entry for 1.3.0,about prismicio/prismic-react ...
... Incompatible with Jest using ESM (`Jest encountered an unexpected token`) HOT 1; PrismicLink: Missing Link Properties error message isn't helpful enough ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found