'How did the method come with value when I didn't pass any props to it?

Here are some of my components. My doubt revolves around the rowRenderer2 function

import React, { useContext, useState } from "react";
import ReactDataGrid, {
  RowRendererProps,
  Row as DataGridRow,
} from "react-data-grid";

import { DataGridContext } from "./context/DataGridContextProvider";
import { Row, DataGridProps } from "./types";

import "./styles/DataGrid.css";
import "./styles/Grid.css";

const DataGrid = (props: DataGridProps): JSX.Element => {
  const {
    className,
    columns,
    rowHeight,
    headerRowHeight,
    handleRowChange,
    ...others
  } = props;
  const { rows } = useContext(DataGridContext);

  const [selectedRows, setSelectedRows] = useState<ReadonlySet<number>>(
    () => new Set(),
  );

  const validationScenario = (title: string) =>
    title === "Budget" || title === "Forecast" || title === "Last Cycle";

  const rowRenderer2 = (rowProps: RowRendererProps<Row>) => {
    const { row } = rowProps;
    const customRow = validationScenario(row.title) ? "custom-scenery" : "";
    return <DataGridRow className={customRow} {...rowProps} />;
  };

  return (
    <ReactDataGrid
      {...others}
      className={className}
      onSelectedRowsChange={setSelectedRows}
      rowKeyGetter={(row: Row) => row.id}
      columns={columns}
      rows={rows.showed}
      rowHeight={rowHeight}
      headerRowHeight={headerRowHeight}
      selectedRows={selectedRows}
      onRowsChange={handleRowChange}
      rowRenderer={rowRenderer2}
    />
  );
};

export { DataGrid };

I would like to know what is the difference of passing it to the component:

 <ReactDataGrid
      {...others}
      rowRenderer={rowRenderer2()}
      className={className}
    />
 <ReactDataGrid
      {...others}
      rowRenderer={() => rowRenderer2()}
      className={className}
    />
 <ReactDataGrid
      {...others}
      rowRenderer={rowRenderer2} //that works, How is the parameter value sent?
      className={className}
    />

And why is it only the third alternative that works? When I just call the method without parentheses, my rowProps comes with a value, but I didn't pass any value to it. Why does it happen? Does the ReactDataGrid rowRenderer parameter itself return a props value for me to work with?

How does the value get in the parameter(rowProps) of the third option when I didn't pass any parameter?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source