It means, records
array is not empty, but somehow id
is not defined. For example:
records = [
{ score: 4.5 },
...
];
Or:
records = [4.5, 5.5, ...]
The solution is checking for validity of record.id
first before checking that it contains this.state.id
, like this:
this.state.records.filter(record =>
this.state.id == '' || (record.id && record.id.includes(this.state.id))
);
UPDATE: If the above still doesn't work, it could be because you're testing it on IE. includes
doesn't work in IE, so you might want to use indexOf
.