Eliott Robert
Eliott Robert

Reputation: 321

DatePickerIOS nothing happen

When i try to use DatePickerIOS with react native nothing happen in my phone ... my code :

import React, { Component } from 'react';
import {Text, View, DatePickerIOS} from 'react-native';

export default class DatePicker extends Component {
    constructor(props) {
        super(props);
        this.state = {
            today: new Date(),
        }
    }

    render() {
        return (
            <View>
                <DatePickerIOS date={this.state.today} mode="time" onDateChange={(value) => this.setState({today: value})}/>
            </View>
        );
    }
}

SomeOn know why ?

Upvotes: 0

Views: 181

Answers (1)

Henrik R
Henrik R

Reputation: 4982

If you want to print selected time in the UI add the following to the render

render() {
  return (
    <View>
      <DatePickerIOS 
        date={this.state.today} 
        mode="time" 
        onDateChange={(value) => this.setState({today: value})}
      />
      <Text>{this.state.today.toTimeString()}</Text>
    </View>
  );
}

Upvotes: 1

Related Questions