简体   繁体   English

为什么我会收到关于作为 React Child 的函数的警告

[英]Why am I getting warning for functions as a React Child on this

what am I missing?我错过了什么? I cant spot it and my grids are not rendering properly.我无法发现它,我的网格没有正确渲染。 I am getting warnings about functions not valid as a React Child.我收到有关作为 React Child 无效的函数的警告。

  render() {
    return (
      <ModalDynamic
        defaultWidth={1200}
        defaultHeight={400}
        defaultX={100}
        defaultY={100}
        display={this.props.showPartsModal}
        title={
          "Parts for Invoice: " +
          (this.props.selectedHistory[0] !== undefined
            ? this.props.selectedHistory[0].invoice_number
            : "N/A")
        }
        dealerPath="[ 12345 ] Some Dealer"
        dismissAction={this.props.dismissAction}
      >
        <div
          //className="ag-theme-bootstrap container-fluid full-height zero-gap modal-container"
          className="ag-fresh container-fluid full-height zero-gap modal-container"
          style={{
            height: "calc(100%)",
            overflowX: "auto"
          }}
          id="viewPartsGrid"
        >
          <AgGridReact
            columnDefs={this.state.columns}
            rowData={this.props.selectedHistory}
            suppressMenuHide="true"
            suppressRowClickSelection="false"
            suppressColumnVirtualisation="false"
            sideBar="false"
            rowSelection="single"
            enableColResize="true"
            enableSorting="true"
            enableFilter="true"
            onGridReady={this.onGridReady}
          />
        </div>
        <div className="rnd-footer">
          <div className="rnd-left">{this.dealerLabel}</div>
          <div className="rnd-right">
            {this.state.gridAPI ? (
              <OverlayTrigger overlay={this.csvTip}>
                <Button
                  className="btn btn-primary btn-sm"
                  onClick={() =>
                    this.state.gridAPI.exportDataAsCsv({
                      fileName:
                        "Parts Invoice #" +
                        (this.props.selectedHistory[0].invoice_number
                          ? this.props.selectedHistory[0].invoice_number
                          : "N/A")
                    })
                  }
                >
                  <i className="fa fa-file-excel-o" />
                </Button>
              </OverlayTrigger>
            ) : null}
          </div>
        </div>
      </ModalDynamic>
    );
  }
}

The code compiles but the grid seems to not do what I am trying to write it to do.代码编译但网格似乎没有做我试图编写它做的事情。 Columns are not resizable and the window itself isn't either.列不能调整大小,窗口本身也不能。

I think this line may give you warning我认为这条线可能会给你警告

 <div className="rnd-left">{this.dealerLabel}</div>

If this is a function that return some static value.如果这是一个返回一些静态值的函数。 Declare that in a new variable在新变量中声明

Example in render渲染示例

const Button = <button onClick={this.yourmethod}>Click Me</button>

return (
   <Button>
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我收到警告 - 函数作为 React 孩子无效。 ……? - why I am getting warning-Functions are not valid as a React child. …? “警告:尝试删除不存在的子项”为什么我在React Native中收到此警告? - “Warning: Trying to remove a child that doesn't exist” Why am I getting this warning in React Native? 为什么我得到 Object 作为 React 孩子无效 - Why am I getting Object are not valid as a React child 为什么我得到 Functions are not valid as a React child? - Why I'm getting Functions are not valid as a React child? 为什么我会收到这个已弃用的警告?! MongoDB - Why am I getting this deprecated warning?! MongoDB 为什么我收到“bodyParser”已弃用警告? - Why am I getting 'bodyParser' is deprecated warning? 为什么我收到以下 React Native 警告:Can&#39;t perform a React state update on an unmounted component - Why am I getting the following React Native warning: Can't perform a React state update on an unmounted component 为什么我会收到此警告以及如何解决它“函数作为 React 子级无效......” - Why do I get this warning and how to fix it "Functions are not valid as a React child..." 警告:函数作为React子元素无效 - Warning: Functions are not valid as a React child 为什么我在 React Redux 减速器中收到关于合成事件的警告? - Why am I getting a warning about synthetic events in my React Redux reducer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM