1

async componentWillMount() {

this.setState({
  mMonthStartDate: moment(new Date()).startof('month').format("YYYY-MM-DD"),
  userAcadDetails: this.props.user.userAcadInfo,
  item: JSON.parse(await AsyncStorage.getAsyncValue("""""""""""))
})

render Method

      <Calendar
        style={{ width: Dimensions.get("window").width }}
        current={this.state.mMonthStartDate}
        minDate={this.state.mMonthStartDate}
        maxDate={this.state.mMonthEndDate}
        onMonthChange={month => {
          // this.getStartdate(month.dateString);
          console.log("month changed", month);
        }}
      />

I am not able to crack this whenever debug JS remotely is on Application perfect. when i turn it off this error will display

krunal patel
  • 25
  • 1
  • 5

3 Answers3

4

In my case I was using markedDates={{}} prop and the reason was that I wasn't passing valid date format which was (YYYY-MM-DD) rather than I was passing (YYYY-M-D). eg :- Valid - 2021-06-06 Invalid - 2021-6-6

rk5422686
  • 41
  • 2
  • This does not provide an answer to the question. [You can search for similar questions](https://stackoverflow.com/search), or refer to the related and linked questions on the right-hand side of the page to find an answer. If you have a related but different question, [ask a new question](https://stackoverflow.com/questions/ask), and include a link to this one to help provide context. See: [Ask questions, get answers, no distractions](https://stackoverflow.com/tour) – jhoepken Jan 14 '21 at 07:36
  • 1
    Actually, this did provide an answer to the question. This is a question specific to the parsing of this library's dates under the hood. The problem is not the user's code. It's the library's code. I did the same thing, but with `current` rather than `markedDates`, and this answer helped me solve it. – Fernando Rojo Apr 16 '21 at 19:02
0

Note: These methods are considered legacy and you should avoid them in new code: UNSAFE_componentWillMount()

I would recommend doing your fetching and async stuff inside of componentDidMount(). The problem is probably that you are trying to set or use some values that are not available atm.

Hayk Shakhbazyan
  • 242
  • 2
  • 15
0

This issue happened for me when I passed wrong date format in the selected property of <Agenda /> component. I fixed the issue by providing the date in correct format i.e. YYYY-MM-DD.

im_tsm
  • 1,965
  • 17
  • 29