期望一个赋值或函数调用,而是看到一个表达式做出反应

时间:2019-05-11 03:02:34

标签: javascript node.js reactjs

我得到那个错误 在这些线上(127/130/138) 我不知道代码到底有什么问题,但是我猜这是一个语法错误或类似的东西? 任何帮助 相同的代码在react-script 1.1.0中工作正常 ps我正在使用react-script 3.0.0

handleDBReponse(response) {
    const appointments = response;
    const today = moment().startOf("day"); //start of today 12 am
    const initialSchedule = {};
    initialSchedule[today.format("YYYY-DD-MM")] = true;
    const schedule = !appointments.length
      ? initialSchedule
      : appointments.reduce((currentSchedule, appointment) => {
          const { slot_date, slot_time } = appointment;
          const dateString = moment(slot_date, "YYYY-DD-MM").format(
            "YYYY-DD-MM"
          );
       !currentSchedule[slot_date] //line 127
            ? (currentSchedule[dateString] = Array(8).fill(false)) 
            : null;
          Array.isArray(currentSchedule[dateString]) //line130

            ? (currentSchedule[dateString][slot_time] = true)
            : null;
          return currentSchedule;
        }
        , initialSchedule);

    for (let day in schedule) {
      let slots = schedule[day];  //138
      slots.length
        ? slots.every(slot => slot === true)
          ? (schedule[day] = true)
          : null
        : null;
    }

1 个答案:

答案 0 :(得分:1)

让我们以以下示例为例:

currentSchedule[slot_date] ?
  (currentSchedule[dateString] = Array(8).fill(false)) 
  : null;

棉绒期望的东西是这样的:

currentSchedule[dateString] = currentSchedule[slot_date] ?
  (Array(8).fill(false)) 
  : null;