我正在尝试设置文本过滤器以在我的react和get error中添加搜索功能无法读取未定义的属性'toLowerCase' 这里的代码可能有帮助
我的代码:
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;
答案 0 :(得分:0)
包含了CSS文件。
我发现一个空属性border-color:;
会导致这种消息。