prismicio / prismic-react

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

asText(undefined) TypeError #57

Closed ohlr closed 4 years ago

ohlr commented 4 years ago

RichText.asText(undefined) results in the following runtime error in development mode. On building the page it causes to fail the build.

Is this intended?

TypeError: Cannot read property 'map' of undefined
r [as asText]
node_modules/prismic-reactjs/dist/prismic-reactjs.js:871
  868 | 
  869 | var r = function (e, t) {
  870 |   var n = "string" == typeof t ? t : " ";
> 871 |   return e.map(function (e) {
  872 |     return e.text;
  873 |   }).join(n);
  874 | };
hypervillain commented 4 years ago

Hey @ohlr, I wouldn't say intended as it's simply passed to RichText, I believe. I'll talk with the dev team if it's something we could change on prismic-dom. In any case, we can add a check in the React package. Would you mind opening a PR?

ohlr commented 4 years ago

so @hypervillain whats the status?

ohlr commented 3 years ago

@hypervillain when do you plan the next release?