Answer the question
In order to leave comments, you need to log in
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
{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 questionAsk a Question
731 491 924 answers to any question