I want to set one of my parent's attributes with my event's start time, but I cant reach this.props from inside the function(info) method. How could I reach tha method I want to use?
eventReceive={function (info) {
this.props.onChangeStartDate(info.start);
}}
onChangeStartDate is one of my parent's function which sets the starting date of an appointment in the parent component and I want to give the event's data which I just added in the calendar as a parameter to that function.
I got the following error:
Cannot read property 'onChangeAppointment' of undefined
Thanks for your help.
The following will solve your error.
eventReceive={(info) => {
this.props.onChangeStartDate(info.start);
}}
Where
() => {}
is an arrow function commonly used. See documentation.
The reason the error is occuring is because you losing the context of this inside the scope of the function.