1
  const onChange = (type) => (e) => {

    const [value, setValue] = useState({
        StartDate : new Date("2021-03-24T23:59:59"),
        EndDate : new Date("2021-03-24T23:59:59"),
        Seperate : false
        });


    if (type == "StartDate" || type == "EndDate") {
      console.clear();
      setValue({
        ...value,
        [type]: new Date(e),
      });
    } else {
      setValue({
        ...value,
        [type]: e.target.value == "on" ? !value[type] : e.target.value,
      });
    }
  };

    <Form.Control as="select" onChange={onChange("Consolidation")}>
    <DateTimePicker onChange={onChange("StartDate")}
    onChange={onChange("StartDate")}

Attempting to understand %100 the above. And I am confused by one item in the above.

  1. What is the purpose of the second (e) in the above function? I know this is the event handler, yet how is this passed to the onChange function from the form controls, being it is only defined with the type parameter.
    I guess the additional => (e) is confusing me. Thanks for your time.
Edison Pebojot
  • 308
  • 3
  • 15
user701236
  • 83
  • 1
  • 7
  • `onChange` is a function that returns another function, `e => ...`. That function is then passed to the `onChange` prop. – Felix Kling Mar 28 '21 at 08:55

0 Answers0