I'm trying to figure out why I'm getting this Type Error: TypeError: Cannot read properties of null (reading 'toString')
The error is coming from this method:
private search = (rows: Array<any>) => {
const columns = rows[0] && Object.keys(rows[0])
return rows.filter((row) =>
columns.some((column : any) => row[column].toString().toLowerCase().indexOf(this.state.queryText.toLowerCase()) > -1)
)
}
I'm just not sure whats causing it or even how to fix it.
This error occurs because an element of the row variable (line 4) is null, so null.toString() is not defined. You could fix this issue with another value check:
columns.some((column : any) => row[column] && row[column].toString().toLowerCase().indexOf(this.state.queryText.toLowerCase()) > -1)