Hey everyone I am running into an error that I am not sure how to resolve. I inherited a project where a previous developer is simply trying to join an array of strings. When I run a build I get the following error in Netlify.
TypeError: this.props.keywords.join is not a function
Here's an example of the code
content: this.props.keywords ? this.props.keywords.join(", ") : ""
Is there something wrong with this.props.keywords ? this.props.keywords.join(", ") : "" that I am just not seeing?
Any help would be appreciated.
Make sure this.props.keywords
is an array:
content: Array.isArray(this.props.keywords) ? this.props.keywords.join(", ") : ""
How Array.isArray
works:
// all following calls return true
Array.isArray([]);
Array.isArray([1]);
Array.isArray(new Array());
Array.isArray(new Array('a', 'b', 'c', 'd'));
Array.isArray(new Array(3));
// Little known fact: Array.prototype itself is an array:
Array.isArray(Array.prototype);
// all following calls return false
Array.isArray();
Array.isArray({});
Array.isArray(null);
Array.isArray(undefined);
Array.isArray(17);
Array.isArray('Array');
Array.isArray(true);
Array.isArray(false);
Array.isArray(new Uint8Array(32));
Array.isArray({ __proto__: Array.prototype });