[英]TypeError: Cannot read property 'toLowerCase' of undefined this error always retrun
I'm trying to set a text filter to add search functionality in my react and get error Cannot read property 'toLowerCase' of undefined here code that may be of help 我正在尝试设置文本过滤器以在我的反应中添加搜索功能并得到错误无法读取此处未定义的代码的“ toLowerCase”属性可能会有所帮助
My Code: 我的代码:
import React, { Component } from "react";
import CardList from "./cardList";
import { robots } from "./robots";
import SearchBox from "./searchBox";
class App extends Component {
constructor() {
super();
this.state = {
robots: robots,
searchfield:''
}
}
onSearchChange = (event) => {
this.setState({searchfield: event.target.value})
}
render() {
const filteredRobots = this.state.robots.filter(robots =>{
return robots.mame.toLowerCase().includes(
this.state.searchfield.toLowerCase());
});
return (
<div className="tc">
<h1> robots Friends </h1>
<SearchBox searchChange={this.onSearchChange}/>
<CardList robots={filteredRobots}/>
</div>
);
}
}
export default App;
Lint included CSS files. 皮棉包括CSS文件。 I found an empty property border-color:;
我发现一个空的属性border-color:;
to cause this kind of message. 引起这种消息。
See: https://stackoverflow.com/a/57772350/1235724 参见: https : //stackoverflow.com/a/57772350/1235724
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.