无法将修改保存在表单中

时间:2018-12-07 14:08:13

标签: reactjs

我有一个正在使用以下方法编辑的表单

editEvent(params) {
    const { event, formValues } = params;
    const { currentUser, editGoogleCalendarEvent, calendarEvents } = this.props;
    const { events } = this.state;

    const idx = calendarEvents.details.items.indexOf(event);
    const editedEvent = {
      id: event.id,
      title: event.summary,
      start: moment(event.start.dateTime || event.start.date),
      end: moment(event.end.dateTime || event.end.date),
    };
    const nextEvents = [...events];
    nextEvents.splice(idx, 1, editedEvent);
    if (idx !== -1) {
      editedEvent.start = formValues.date.hours(formValues.period === 'AM' ? formValues.hour % 12 : (formValues.hour % 12) + 12).minutes(formValues.minute).toISOString();
      editedEvent.end = formValues.date.hours(formValues.period === 'AM' ? formValues.hour % 12 : (formValues.hour % 12) + 12).minutes(formValues.minute).toISOString();
      editedEvent.title = formValues.title;
      editedEvent.description = formValues.description;
    }

    this.setState({
      events: nextEvents,
    }, () => {
      editGoogleCalendarEvent({ ...editedEvent, userId: currentUser.id, timezone: currentUser.timezone });
    });
  }

以某种方式我无法保存描述字段的编辑。可能是什么问题?

0 个答案:

没有答案