简体   繁体   中英

Objects are not valid as a React child (found: object with keys {this}). If you meant to render a collection of children, use an array instead

This gives an error: This is normal text. how to solve this problem in react its file of layout im using visual studio So is this, but now follows a code block:

export default class Layout extends React.Component {
  constructor(props) {
    super(props);

    this.identify = this.identify.bind(this);
  }
  identify() {
    if (this.props.dashboard) {
      return (
        <div>
          <Header />
          <Container>{this.props.children}</Container>
          <Footer />
        </div>
      );
    } else {
      return (
        <div className="flexible-content">
          <TopNavigation />
          <SideNavigation />
          <main id="content" className="p-5">
            {this.props.children}
          </main>
          <DashFooter />
        </div>
      );
    }
  }

  render() {
    return { this: this.identify };
  }
}

You just need to call identify method which returns JSX in your case

render() {
    return this.identify();
  }

You need to return valid JSX from the render function. Right now you're returning an object of { this: this.identify }. You just need to return this.identify()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Objects are not valid as a React child (found: object with keys {children}). If you meant to render a collection of children, use an array instead Objects are not valid as a React child (found: object with keys {value}). If you meant to render a collection of children, use an array instead Objects are not valid as a React child (found: object with keys {weight}). If you meant to render a collection of children, use an array instead Objects are not valid as a React child (found: object with keys {_delegate}). If you meant to render a collection of children, use an array instead Objects are not valid as a React child (found: object with keys {arr}). If you meant to render a collection of children, use an array instead Objects are not valid as a React child (found: object with keys {totalItems}). If you meant to render a collection of children, use an array instead How to fix Objects are not valid as a React child (found: object with keys {}). If you meant to render a collection of children, use an array instead Error: Objects are not valid as a React child (found: object with keys {rank}). If you meant to render a collection of children, use an array instead Error: Objects are not valid as a React child (found: object with keys {}). If you meant to render a collection of children, use an array instead. JS Uncaught Error:Objects are not valid as a React child (found: object with keys.If you meant to render a collection of children, use an array instead
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM