1. First introduce the Datepickerios component as shown in the code set his time is the current time
Export default class Alertdemo extends Component { render () { return ( <view Style={styles.container} > <datepickerios date={new Date ()} mode= "Time"/> </View> );} }
Where the mode attribute represents the total of his display mode is ' date ', ' Time ', ' datetime ', these three modes
However, this status is selected and will be returned to the current time so the State property should be set as follows
Export default class Alertdemo extends Component { static defaultprops ={ date:new date () //Initialize static current time } Constructor (props) { super (props); this.state={ //Dynamic state Date:this.props.date } } render () { return ( <view style={styles.container}> <datepickerios date={this.state.date} ondatechange={(date) = This.setstate ({date})}//start this function mode= ' time '/> </View>) when the content changes ;} }
This allows you to resolve changes that do not appear and automatically run to the current time after changing the time
React Native's Datepickerios components