javascript icon indicating copy to clipboard operation
javascript copied to clipboard

authorName is null => Cannot read property 'length' of null

Open goaround opened this issue 4 years ago • 1 comments

Explanation

On my terms (categories, tags...) I always get the following error:

react-dom.min.js?ver=16.13.1:125 TypeError: Cannot read property 'length' of nullt FacebookSiteAndAuthorNames (FacebookSiteAndAuthorNames.js?6a79:66)

It happens because props.authorName is null on my sites and the functions check the props.authorName.length > 0: https://github.com/goaround/javascript/blob/12520ef960f8c1f7789c337354f160a3fc3ac98c/packages/social-metadata-previews/src/facebook/FacebookSiteAndAuthorNames.js#L66

I would suggest to check first if props.authorName is not null before checking the length.

goaround avatar Jul 12 '21 11:07 goaround

Pull request: https://github.com/Yoast/javascript/pull/1199

goaround avatar Jul 12 '21 11:07 goaround