在三元运算符的真实部分如何做?

问题描述

searchBook(inputSearch) {
    const { searchResult } = this.state;
    const { read,currentlyReading,wantToRead } = this.props;
    const mainPageBooks = [...read,...currentlyReading,...wantToRead];
    console.log(mainPageBooks);
    BooksAPI.search(inputSearch,20).then((books) => {
      books.length > 0?
    (for (const book of mainPageBooks)
    { books.filter(b=>b.id===book.id).map(b=>b.shelf=book.shelf)},this.setState({
            searchResult: books,searchError: false,}))
     
: ( this.setState({
            searchResult: [],searchError: true,}))
      if (this.state.query === "")
        this.setState({
          searchResult: [],});
      return searchResult;
    });
  }

如果你输入用 react.js 编写的这段代码,你会在代码下发现错误行,我该如何修复它,当它为真时,我需要在三元条件的结果中做 2 条语句。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)