david
david

Reputation: 1

react error - Cannot update during an existing state transition (such as within `render`)

  if(props.filterCriteria.timeRange){
    const start = props.filterCriteria.timeRange.start
    const end = props.filterCriteria.timeRange.end
    form.setFieldsValue({
      created: [moment(start, 'YYYY-MM-DD HH:mm:ss'), moment(end, 'YYYY-MM-DD HH:mm:ss')]
    })
  }

Add this to the function component and report an error: Warning: Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state.

Upvotes: 0

Views: 369

Answers (1)

ZiggidyCreative
ZiggidyCreative

Reputation: 335

Call the setFieldsValue from within useEffect.

Upvotes: 2

Related Questions