简体   繁体   English

TypeError:无法读取未定义的属性“ toLowerCase”,此错误总是重新运行

[英]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.

相关问题 我有错误未捕获的TypeError:无法读取未定义的属性&#39;toLowerCase&#39; - I have the error Uncaught TypeError: Cannot read property 'toLowerCase' of undefined Angular 5:错误类型错误:无法读取未定义的属性“toLowerCase” - Angular 5 : ERROR TypeError: Cannot read property 'toLowerCase' of undefined 未捕获的TypeError:无法在文本字段上读取未定义错误的属性“ toLowerCase” - Uncaught TypeError: Cannot read property 'toLowerCase' of undefined Error on text field 错误类型错误:无法读取 Pipe 未定义的属性“toLowerCase” - ERROR TypeError: Cannot read property 'toLowerCase' of undefined for Pipe Angular 6:ERROR TypeError:无法读取未定义的属性&#39;toLowerCase&#39; - Angular 6: ERROR TypeError: Cannot read property 'toLowerCase' of undefined 错误类型错误:无法读取未定义的属性“toLowerCase”。 离子 3 - ERROR TypeError: Cannot read property 'toLowerCase' of undefined. Ionic 3 获取错误未捕获的TypeError:无法读取未定义的属性“ toLowerCase” - Getting error Uncaught TypeError: Cannot read property 'toLowerCase' of undefined 未捕获的TypeError:无法读取属性toLowerCase的未定义 - Uncaught TypeError: Cannot read property toLowerCase of undefined 类型错误:无法在反应中读取未定义的属性“toLowerCase” - TypeError: Cannot read property 'toLowerCase' of undefined in react 茉莉花:TypeError:无法读取未定义的属性“ toLowerCase” - Jasmine: TypeError: Cannot read property 'toLowerCase' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM