I
I
IIITRIX2019-02-15 11:32:42
WordPress
IIITRIX, 2019-02-15 11:32:42

How to fix Cannot read property 'length' of undefined?

I'm trying to deploy ( npm run build ) with create-react-app
in dev version, it works fine, but it gives an error when building

Uncaught (in promise) TypeError: Cannot read property 'length' of undefined

Here is the code that swears
{articles.length > 0 ? (
 articles.map((article, index) => {
  const content_blocks = article.content
  ? JSON.parse(article.content).blocks
  : [];
  return (
   <React.Fragment key={index}>
     <ReactPlaceholder
       showLoadingAnimation
       delay={2000}
       ready={this.props.ready}
       customPlaceholder={ArticlePlaceholder}
    >
   <SingleArticle
    article={article}
    content_blocks={content_blocks}
    article_index={index}
    subsiteDetailPageView={this.props.subsiteDetailPageView}
   />
  </ReactPlaceholder>
 </React.Fragment>
 );
 })
 ) : (
 <NoArticlesFound />
 )}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question