Tag Archives: React Error

React Error: Need at least a key or a value or a label (only for OptGroup) for [object Object]

antd select  Component option value is empty

Find the assignment option and print the original data

Reason: a piece of useless data is returned in the background. For this error, the returned data will be filtered directly in the background; In order to avoid the front-end error caused by such useless data; The front-end adds judgment and filters data;

 let hospSelect = []
                    for (var i = 0; i < res.Hosp.length; i++) {
                        if(res.Hosp[i].id&&res.Hosp[i].descripts) hospSelect.push({res.Hosp[i].descripts})
                    }
                    this.setState({
                        hospSelect,
                    })

React Error: Import in body of module; reorder to top import/first

The reason is as follows:

I divide a component into three files

|—Home.jsx         //  Business logic and html
         Home-|-Home.css // style
               |-index.js // Introduce Home.css , then expose the Home component

Index.js is the export of home.js and the import of home.css. The code is as follows:

export { default } from "./Home.jsx";
import "./Home.css";

So, then, it’s wrong. It’s OK to write like this before. Google search says that it’s because of this:

import must precede all other business codes (eslint burst), import must precede all other business codes

If an asynchronous component is imported, it can not be inserted in front of other imported items. If an asynchronous component is imported, it can not be inserted in front of other imported items

similar behavior will report this error

Change it to this:

import "./Home.css";
export { default } from "./Home.jsx";

Well, I’m just changing places here