How to create CallBack method to get value from an

2019-08-06 19:00发布

I have create CustomDatePicker.JS file for datePicker, for Android use the DatePickerAndroid and for ios use DatePickerIOS, and its use in my another Profile.js file. I use like below.

<CustomDatePicker ref='modal'></CustomDatePicker>

Now whenever will select the date, CustomDatePicker.JS class get the value but I want to the date value in Profile.js. So how can get date value in profile.

CustomDatePicker.JS : Here Will get date and time log. Profile.js : Want to date which is selected on CustomDatePicker.

I hope, You are underStand...

Thanks.

1条回答
对你真心纯属浪费
2楼-- · 2019-08-06 20:05

In your Profile.js, i.e Profile component you can pass some callback fn as props like,

<CustomDatePicker 
  mode="date"
  onDateChange={date => this.onDateChange(date)}
  ref='modal'>
</CustomDatePicker>

In you CustomDatePicker.js, i.e CustomDatePicker component where you have defined DatePickerIOS, you can use those props.

<DatePickerIOS
   {...this.props}
/>
查看更多
登录 后发表回答