GithubHelp home page GithubHelp logo

mmazzarolo / react-native-modal-datetime-picker Goto Github PK

View Code? Open in Web Editor NEW
2.9K 33.0 388.0 5.29 MB

A React-Native datetime-picker for Android and iOS

License: MIT License

JavaScript 64.48% Java 16.57% Objective-C 11.81% Ruby 2.03% Starlark 5.11%
react react-native modal date time picker ios android

react-native-modal-datetime-picker's Introduction

react-native-modal-datetime-picker

npm version Supports Android and iOS

A declarative cross-platform react-native date and time picker.

This library exposes a cross-platform interface for showing the native date-picker and time-picker inside a modal, providing a unified user and developer experience.

Under the hood, this library is using @react-native-community/datetimepicker.

Setup (for non-Expo projects)

If your project is not using Expo, install the library and the community date/time picker using npm or yarn:

# using npm
$ npm i react-native-modal-datetime-picker @react-native-community/datetimepicker

# using yarn
$ yarn add react-native-modal-datetime-picker @react-native-community/datetimepicker

Please notice that the @react-native-community/datetimepicker package is a native module so it might require manual linking.

Setup (for Expo projects)

If your project is using Expo, install the library and the community date/time picker using the Expo CLI:

npx expo install react-native-modal-datetime-picker @react-native-community/datetimepicker

To ensure the picker theme respects the device theme, you should also configure the appearance styles in your app.json this way:

{
  "expo": {
    "userInterfaceStyle": "automatic"
  }
}

Refer to the Appearance documentation on Expo for more info.

Usage

import React, { useState } from "react";
import { Button, View } from "react-native";
import DateTimePickerModal from "react-native-modal-datetime-picker";

const Example = () => {
  const [isDatePickerVisible, setDatePickerVisibility] = useState(false);

  const showDatePicker = () => {
    setDatePickerVisibility(true);
  };

  const hideDatePicker = () => {
    setDatePickerVisibility(false);
  };

  const handleConfirm = (date) => {
    console.warn("A date has been picked: ", date);
    hideDatePicker();
  };

  return (
    <View>
      <Button title="Show Date Picker" onPress={showDatePicker} />
      <DateTimePickerModal
        isVisible={isDatePickerVisible}
        mode="date"
        onConfirm={handleConfirm}
        onCancel={hideDatePicker}
      />
    </View>
  );
};

export default Example;

Available props

👉 Please notice that all the @react-native-community/react-native-datetimepicker props are supported as well!

Name Type Default Description
buttonTextColorIOS string The color of the confirm button texts (iOS)
backdropStyleIOS style The style of the picker backdrop view style (iOS)
cancelButtonTestID string Used to locate cancel button in end-to-end tests
cancelTextIOS string "Cancel" The label of the cancel button (iOS)
confirmButtonTestID string Used to locate confirm button in end-to-end tests
confirmTextIOS string "Confirm" The label of the confirm button (iOS)
customCancelButtonIOS component Overrides the default cancel button component (iOS)
customConfirmButtonIOS component Overrides the default confirm button component (iOS)
customHeaderIOS component Overrides the default header component (iOS)
customPickerIOS component Overrides the default native picker component (iOS)
date obj new Date() Initial selected date/time
isVisible bool false Show the datetime picker?
isDarkModeEnabled bool? undefined Forces the picker dark/light mode if set (otherwise fallbacks to the Appearance color scheme) (iOS)
modalPropsIOS object {} Additional modal props for iOS
modalStyleIOS style Style of the modal content (iOS)
mode string "date" Choose between "date", "time", and "datetime"
onCancel func REQUIRED Function called on dismiss
onChange func () => null Function called when the date changes (with the new date as parameter).
onConfirm func REQUIRED Function called on date or time picked. It returns the date or time as a JavaScript Date object
onHide func () => null Called after the hide animation
pickerContainerStyleIOS style The style of the picker container (iOS)
pickerStyleIOS style The style of the picker component wrapper (iOS)
pickerComponentStyleIOS style The style applied to the actual picker component - this can be either a native iOS picker or a custom one if customPickerIOS was provided

Frequently Asked Questions

This repo is only maintained by me, and unfortunately I don't have enough time for dedicated support & question. If you're experiencing issues, please check the FAQs below.
For questions and support, please start try starting a discussion or try asking it on StackOverflow.
⚠️ Please use the GitHub issues only for well-described and reproducible bugs. Question/support issues will be closed.

The component is not working as expected, what should I do?

Under the hood react-native-modal-datetime-picker uses @react-native-community/datetimepicker. If you're experiencing issues, try swapping react-native-datetime-picker with @react-native-community/datetimepicker. If the issue persists, check if it has already been reported as a an issue or check the other FAQs.

How can I show the timepicker instead of the datepicker?

Set the mode prop to time. You can also display both the datepicker and the timepicker in one step by setting the mode prop to datetime.

Why is the initial date not working?

Please make sure you're using the date props (and not the value one).

Can I use the new iOS 14 style for the date/time picker?

Yes!
You can set the display prop (that we'll pass down to react-native-datetimepicker) to inline to use the new iOS 14 picker.

Please notice that you should probably avoid using this new style with a time-only picker (so with mode set to time) because it doesn't suit well this use case.

Why does the picker show up twice on Android?

This seems to be a known issue of the @react-native-community/datetimepicker. Please see this thread for a couple of workarounds. The solution, as described in this reply is hiding the modal, before doing anything else.

Example of solution using Input + DatePicker

The most common approach for solving this issue when using an Input is:

  • Wrap your Input with a "Pressable"/Button (TouchableWithoutFeedback/TouchableOpacity + activeOpacity={1} for example)
  • Prevent Input from being focused. You could set editable={false} too for preventing Keyboard opening
  • Triggering your hideModal() callback as a first thing inside onConfirm/onCancel callback props
const [isVisible, setVisible] = useState(false);
const [date, setDate] = useState('');

<TouchableOpacity
  activeOpacity={1}
  onPress={() => setVisible(true)}>
  <Input
    value={value}
    editable={false} // optional
  />
</TouchableOpacity>
<DatePicker
  isVisible={isVisible}
  onConfirm={(date) => {
    setVisible(false); // <- first thing
    setValue(parseDate(date));
  }}
  onCancel={() => setVisible(false)}
/>

How can I allow picking only specific dates?

You can't — @react-native-community/datetimepicker doesn't allow you to do so. That said, you can allow only "range" of dates by setting a minimum and maximum date. See below for more info.

How can I set a minimum and/or maximum date?

You can use the minimumDate and maximumDate props from @react-native-community/datetimepicker.

How do I change the color of the Android date and time pickers?

This is more a React-Native specific question than a react-native-modal-datetime-picker one.
See issue #29 and #106 for some solutions.

How to set a 24-hours format in iOS?

The is24Hour prop is only available on Android but you can use a small hack for enabling it on iOS by setting the picker timezone to en_GB:

<DatePicker
  mode="time"
  locale="en_GB" // Use "en_GB" here
  date={new Date()}
/>

How can I change the picker language/locale?

Under the hood this library is using @react-native-community/datetimepicker. You can't change the language/locale from react-native-modal-datetime-picker. Locale/language is set at the native level, on the device itself.

How can I set an automatic locale in iOS?

On iOS, you can set an automatic detection of the locale (fr_FR, en_GB, ...) depending on the user's device locale. To do so, edit your AppDelegate.m file and add the following to didFinishLaunchingWithOptions.

// Force DatePicker locale to current language (for: 24h or 12h format, full day names etc...)
NSString *currentLanguage = [[NSLocale preferredLanguages] firstObject];
[[UIDatePicker appearance] setLocale:[[NSLocale alloc]initWithLocaleIdentifier:currentLanguage]];

Why is the picker is not showing the right layout on iOS >= 14?

Please make sure you're on the latest version of react-native-modal-datetime-picker and of the @react-native-community/datetimepicker. We already closed several iOS 14 issues that were all caused by outdated/cached versions of the community datetimepicker.

Why is the picker not visible/transparent on iOS?

Please make sure you're on the latest version of react-native-modal-datetime-picker and of @react-native-community/datetimepicker. Also, double-check that the picker light/dark theme is aligned with the OS one (e.g., don't "force" a theme using isDarkModeEnabled).

Why can't I show an alert after the picker has been hidden (on iOS)?

Unfortunately this is a know issue with React-Native on iOS. Even by using the onHide callback exposed by react-native-modal-datetime-picker you might not be able to show the (native) alert successfully. The only workaround that seems to work consistently for now is to wrap showing the alter in a setTimeout 😔:

const handleHide = () => {
  setTimeout(() => Alert.alert("Hello"), 0);
};

See issue #512 for more info.

Why does the date of onConfirm not match the picked date (on iOS)?

On iOS, clicking the "Confirm" button while the spinner is still in motion — even just slightly in motion — will cause the onConfirm callback to return the initial date instead of the picked one. This is is a long standing iOS issue (that can happen even on native app like the iOS calendar) and there's no failproof way to fix it on the JavaScript side.
See this GitHub gist for an example of how it might be solved at the native level — but keep in mind it won't work on this component until it has been merged into the official React-Native repo.

Related issue in the React-Native repo here.

How do I make it work with snapshot testing?

See issue #216 for a possible workaround.

Contributing

Please see the contributing guide.

License

The library is released under the MIT license. For more details see LICENSE.

react-native-modal-datetime-picker's People

Contributors

alimek avatar cvblixen avatar dependabot[bot] avatar fabiopaiva avatar fobos531 avatar gbhasha avatar iroachie avatar joeaverage1234 avatar kapilratnani avatar keepitrio avatar kolking avatar lukemcgregor avatar madc avatar mars-lan avatar mj0826 avatar mmazzarolo avatar mujavidb avatar nacmartin avatar nicoleetlui avatar nikolaiwarner avatar oalsing avatar ocarreterom avatar oliveroneill avatar patlux avatar rockhalil avatar rodrigofeijao avatar semantic-release-bot avatar somecatdad avatar srmagura avatar sudoplz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-modal-datetime-picker's Issues

iOS datetime picker keeps previous date

My situation:

  1. A form has your datetime picker field.
  2. When I open the form set time and submit the form.
  3. Open the form again with changed time (default value is used).
  4. But when you open datetime picker old value is there.

I've reviewed code in https://github.com/mmazzarolo/react-native-modal-datetime-picker/blob/master/src/CustomDatePickerIOS/index.js and noticed that there is no any code to update this.state.date.

There is a workaround: unload form/field and load it again.

Please fix it to avoid component unloading.

Android Time picker gives wrong time

Android time picker gives the wrong time inputted as output.

I fixed this by editing line 81 of src/index.js

const date = new Date();
date.setHours(hour, minute, 0, 0)

Suggestions: Creating common Props for android and ios

We have to use different Props name for Android and IOS.

Android:

  1. minDateAndroid
  2. maxDateAndroid

IOS:

  1. minimumDate
  2. maximumDate

Can we create common property for this like we can use only minimumDate and maximumDate for both Android and IOS.

Bug: Some Weird Behaviour

When we set picked date in state, and if we try to get the date from state it give old date instead of picked date.

import React, { Component } from 'react'
import { Text, TouchableOpacity, View } from 'react-native'
import DateTimePicker from 'react-native-modal-datetime-picker'

export default class DateTimePickerTester extends Component {
  state = {
    date: new Date(),
    isDateTimePickerVisible: false
  }

  _loadFromServer = () => {
   // In this code this.state.date prints old date instead new picked date
    console.log(this.state.date)
  }
  _showDateTimePicker = () => this.setState({ isDateTimePickerVisible: true })

  _hideDateTimePicker = () => this.setState({ isDateTimePickerVisible: false })

  _handleDatePicked = (date) => {
    console.log('A date has been picked: ', date)
    // Set picked date to state
    this.setState({ date: date })
    this._hideDateTimePicker()
    this._loadFromServer()
  }

  render () {
    return (
      <View style={{ flex: 1 }}>
        <TouchableOpacity onPress={this._showDateTimePicker}>
          <Text>Show TimePicker</Text>
        </TouchableOpacity>
        <DateTimePicker
          isVisible={this.state.isDateTimePickerVisible}
          onConfirm={this._handleDatePicked}
          onCancel={this._hideDateTimePicker}
        />
      </View>
    )
  }

}

DateTimePicker in 'time' mode resets non-time portions of Date object

Set up a DateTimePicker set to mode="time" with date={someDatePastOrFuture}. Select a new time via the picker and examine the date object sent to the onConfirm function.

On iOS, the old year, month, and day remain the same but the time has been updated, as expected.

On Android, the time updates as expected, but the year, month, and day have been replaced with today.

How Can I disable Current Dates and Future Dates?

I am using this Module But How Can I Disable Future and Current Dates...

_handleDatePicked = (date) => {
    var DateFormat =  moment(date).format("YYYY-MM-DD");
     console.log('A date has been picked:'+DateFormat);

     var d1 =new Date();
    d1.setHours(0,0,0,0)
     var d = new Date(DateFormat);
     d.setHours(0,0,0,0)
    var n = d.getDate();
    var m = d1.getDate();
    
    if(m < n){
        Alert.alert("Hello", 'Current Date and Future Dates Not allowing')  
        console.log("n:"+n +":"+"m:"+m) 
        }
        else{
           this.setState({
          DateOfBirth:DateFormat
         })
       } 
     this._hideDateTimePicker();
   };

This Code Is Not Allowing Future Dates But Allowing CurrentDate , I want Disable Current Date Also

How to open both date and time picker?

For me only date picker modal open, no time picker.
I followed same code as in example.

Android 6
I am using react-native-modal-datetime-picker: "^3.0.1",

Custom Calendar

Hi,
Is there anyway to implement custom calendar such as persian calendar?

Warning on mode 'datetime'

Hi there,

First, thanx for your package that saved me a lot of time !
I just would like to report you a warning that appears when I set the 'datetime' mode :
Warning: Failed prop type: Invalid propmodeof valuedatetimesupplied toCustomDatePickerIOS, expected one of ["date","time"].
I think it would be easy to correct.

Error in recent react-native version

I recently updated to new react-native 0.46.1 and following bugs appear in this library.
It appears when I set isVisible state to true.

image

please fix this issue in npm module. Thank you.

Only the date picker shows up, not the time picker

I might be applying this wrong but I copy the example and a time picker does not show up for me however the console log still prints out a time when a date is selected. How can I make the time picker show up as well?

Time range picker

Can you support picking multiple times or a range of times when I open the Calendar for a day

How can i set a format?

Hello,
How can i set a format to the datepicker to pick the data like yyyy-mm-dd.

Example
2017-08-14

how to show date and time?

I was trying to change the mode prop to 'datetime' but it is not working, how I can show date and time, and I am talking about both iphone and ios.

Thank you

DatePickerIOS property minuteInterval not working

I've added a DatePicker with a mode of 'time' and it continues to show 1 minute intervals despite setting the minuteInterval to 30.
I've also tried all the other possible values. None of them seem to work.

Feature request: option to force timezone

Currently the picker return a complete date with the local timezone. When picking a date like a birthdate, it can be an issue. For example if my device local timezone is UTC+01 and I select 2000-01-01 as my birthdate, the picker would return 2000-01-01 00:00:00+01. If I convert it to UTC(z) (the default date format used by JSON for example) it would be converted to 1999-12-31:23:00:00.000Z.
So it would be good to have an option to tell the picker that the returned date should have no timezone (wich would result to UTC+0) or, better, to enforce it's timezone (in which case it could be set to 0 if we want UTC+0 but also any other value like -5 if we want UTC-5 for example). If this option is not set, returned dates would default to use the local timezone of course.

How to support landscape orientation for my view??

How to support landscape orientation for this component?

hello @mmazzarolo,
update:
I use your examples, first, let mobile phone in landscape state, your examples app will be in a horizontal screen, and then click 'Show TimePicker', at this time, app forced change to vertical orientation when show TimePicker...and ui will show the issure.

Weird header in android when maximumDate is setted

Hi, first of all, thank you for making this nice module.

When i set the property maximumDate it works as expected in both platforms, but in android it shows an ugly header, this error is not shown when i set the minimumDate prop.

screenshot_1498099830

This is my code

<DateTimePicker
            isVisible={this.state.showDob}
            titleIOS="Select Your Birth Day"
            maximumDate={Moment().subtract(18, 'years').startOf('day').toDate()}
            onConfirm={date=>{
              dob.onChange(Moment(date).format("YYYY/MM/DD"))        
              this.setState({showDob: false})
            }}
            onCancel={()=>{this.setState({showDob: false})}}/>```

Crashes iOS app when using debugger

While using the in browser debugger with React Native, this library freezes up the iOS app when displaying the modal leading to crash. I am using the example in the Usage section of the ReadMe. Works fine when debugger is turned off.

Android - DatePicker opens on November 2100

Hi,
In some android device (Nura), the datepicker opens on November 2100.

<DateTimePicker
          minimumDate={new Date()}
          isVisible={this.state.isDateTimePickerVisible}
          onConfirm={this._handleDatePicked}
          onCancel={this._hideDateTimePicker}
         />

Any ideas ?
Thanks a lot.

showing error on iOS simulator (create-react-native-app) environment

throwing error on iOS.
See screen shot below for the error.

Code:

import React, { Component } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import DateTimePicker from 'react-native-modal-datetime-picker';

export default class DateTimePickerTester extends Component {
  state = {
    isDateTimePickerVisible: false,
  };

  _showDateTimePicker = () => this.setState({ isDateTimePickerVisible: true });

  _hideDateTimePicker = () => this.setState({ isDateTimePickerVisible: false });

  _handleDatePicked = (date) => {
    console.log('A date has been picked: ', date);
    this._hideDateTimePicker();
  };

  render () {
    return (
      <View style={{ flex: 1, marginTop: 50 }}>
        <TouchableOpacity onPress={this._showDateTimePicker}>
          <Text>Show TimePicker</Text>
        </TouchableOpacity>
        <DateTimePicker
          isVisible={this.state.isDateTimePickerVisible}
          onConfirm={this._handleDatePicked}
          onCancel={this._hideDateTimePicker}
        />
      </View>
    );
  }
}

Depencencies used

  "dependencies": {
    "expo": "19.0.0",
    "moment": "2.18.1",
    "react": "16.0.0-alpha.12",
    "react-native": "0.46.1",
    "react-native-deprecated-custom-components": "0.1.1",
    "react-native-keyboard-spacer": "0.3.1",
    "react-native-material-textfield": "0.8.1",
    "react-native-modal-datetime-picker": "^4.9.0",
    "redux": "3.7.2"
  }

screen shot 2017-07-27 at 8 22 52 pm

Typescript typings

Interested in having typescript typings? For those using typescript with react native. I already started on it

DatePickerIOS minuteInterval prop doesn't work.

<DateTimePicker
     mode="time"
     minuteInterval='15'
     isVisible={ this.state.pickerOpened }
     onCancel={() => this.setState({pickerOpened: false}) }
     onConfirm={(date) => {
         this.setState({pickerOpened: false});
     }}
 />

Should display 00, 15, 30, 45 for the minutes, but instead shows 0-59

Add license file?

Hello,

I would like to use it in my project ,but license file is missing here so I can not use it.
Thanks.

onHideAfterConfirm is not working

onHideAfterConfirm behavior does not work at all on both Android and iOS.
By looking at both "index.js", master branch seems to indicate the behavior is implemented and supported. Nevertheless, this implementation is not observed after performing an "npm install react-native-modal-datetime-picker". There is no mention of onHideAfterConfirm in the code that is retrieved by npm install.

EDIT - Version I'm running:
react-native-cli: 2.0.1
react-native: 0.44.0
[email protected]

App crashes on minimumDate

Setting minimum date crash app

<DateTimePicker
    isVisible={this.state.isDateTimePickerVisibleTo}
    onConfirm={this._handleDatePickedTo}
    onCancel={this._hideDateTimePickerTo}
    minimumDate={this.state.dateFrom}
    maximumDate={new Date()}
     />

this.state.dateFrom cames from another date picker
and the code was working before when I commented minimumDate every thing works fine

Date and time seperate

Hey just another question, even when I set the mode to 'time' or 'date', the opposite picker would sometimes pop up. I've been looking at it and I've checked and i'm not sure if it's my own mistake or not.

Dialog displays multiple times in list view

I'm trying to use the datetime picker in the list view to changes the dates on each row. However when a row is clicked the dialog is shown multiple time (for each row) and the first row it does not show at all.

Below is some example code that shows the problem. I may just be doing it wrong. :)

import React, { Component,PropTypes } from "react";
import { AppRegistry,ScrollView,Text,View} from "react-native";
import DateTimePicker from "react-native-modal-datetime-picker";

var list=new Array();
class Example extends Component {

	state = {
		isDateTimePickerVisible: false
	}

	_showDateTimePicker = () => this.setState({ isDateTimePickerVisible: true})
	_hideDateTimePicker = () => this.setState({ isDateTimePickerVisible: false })

	_handleDatePicked = (seq, date) => {
		list[seq].time=date;
		this._hideDateTimePicker();
	}
  render() {
    if (list.length == 0) {	
		for (let i=0;i<3;i++) {
			let tmp =  new Object();
			tmp.seq=i;
			tmp.time=new Date(1478546600000+(i*24*60*60*1000));
			list.push(tmp);
		}
	}
	return (<View><ScrollView>{this.renderRows()}</ScrollView></View>);
  }
  
  renderRows() {
    return list
      .map((data) => {
			return (
			<View key={data.seq} style={{flex: 1, flexDirection: "row", justifyContent: "space-between"}}>
				<Text>{data.time.toString()}</Text>
				<Text onPress={this._showDateTimePicker.bind(this,data.seq)}>Set Time</Text>
				<DateTimePicker
				key={data.seq} 
				mode="datetime"
				date={data.time}
				isVisible={this.state.isDateTimePickerVisible}
				onConfirm={this._handleDatePicked.bind(this,data.seq)}
				onCancel={this._hideDateTimePicker}
				/>
			</View>
			)
		})
	}
}	
  
AppRegistry.registerComponent("Example", () => Example);


iOS title and buttons style personnalization

Hey mmazzarolo,
Your package is working very fine and it globally looks pretty, especially on Android.
On iOS, title and buttons are not customizable and it would be great to have the possibility to change the font color and size of the title and the confirm and cancel buttons for example. The background color of the modals could be great to custom too !

Native iOS modal
Image of Yaktocat

In your package, it looks like the native modal buttons but they are bigger than on the native modal. Moreover, the cancel button has a bold font weight and not the confirm one.
If everybody could customize this, that would be awesome (and your package would become perfect ;) )

Your package modal
Image of Yaktocat

Last thing, the cancel button is separated from the modal and (in my opinion), it would far prettier if it would looks like the native modal (elegantly separated from the confirm button by a border as in the native iOS modal). What do you think about give us the possibility to choose between separated cancel button, native-like cancel button and no cancel button at all ?

ios modal container style

nice and lite component.
would be great to see possibility to change modal container in the same way as customTitleContainerIOS, datePickerContainerStyleIOS done

minuteInterval not working

Expected behavior:
passing prop minuteInterval={15} should show time in 15 minutes interval.

Actual behavior:
1 minute interval

DateTimePicker stops working when you unmount the component

DateTimePicker stops working when you unmount the component.

I display a list of tasks, when changing the date the component is dismounted and the datetimepicker stops working immediately, returning only when it closes the emulator and opens again.

datetimepicker1

Code example:

  ...

  render() {
    const { visibleDateTimePicker } = this.state;
    const { dailyTask } = this.props;

    return (
      <Card borderColor="#F4B937">
        <CardHeader onPress={this.onOpenActionSheet} />
        <CardBody>
          <Title>
            {dailyTask.title}
          </Title>
          <HelperContainer>
            <HelperText>Adicionado </HelperText>
            <FormattedRelativeTime
              style={styles.formattedRelativeTime}
              value={new Date(dailyTask.createdAt)}
              unit="best"
            />
          </HelperContainer>
          <Description>
            {dailyTask.description}
          </Description>
        </CardBody>
        <DateTimePicker
          isVisible={visibleDateTimePicker}
          onConfirm={dueDate => this.handleEdit({ dueDate }, dailyTask)}
          onCancel={() => this.setVisibleDateTimePicker(false)}
        />
      </Card>
    );
  }

Not work in "Remote JS Debug" mode

Versions:

"react": "15.4.2",
"react-native": "0.42.0",
"react-native-modal-datetime-picker": "^4.1.0",

I just copy the code from READEME.md.
In "Remote JS Debug" mode, it don't work in simulator. The TouchableOpacity just keep highlight and nothing happens. When some other operations taked, it will crash. My iPhone(6s Plus, 10.2.1), same as simulator.

But not in "Remote JS Debug" mode, it works well both simulator and iPhone.

Edit: On android(SAMSUNG Galaxy S6, Android 5.1.1) all works well.

is24Hour param is ignored for mode='datetime' scenario

When settings mode='datetime' the timepicker ignores the is24Hour flag

the issue is in src/CustomDatePickerAndroid/index.js:52-54 where the is24Hour prop should be added to the time options.

let me know If you want a PR for that.

Getting date value after custom confirm button

First, thanks for the great module.

I am trying to use the custom confirm button option so I create a Button like so

<customConfirmButtonIOS={<Button
              title="Confirm"
              onPress={this._handleTimePicked}
              />}

the problem is that the onPress function doesn't seem to receive the selected date value in the same way that the built-in confirm button passes it along. I tried setting ref for the DateTimePicker to simply grab it from the function but I not sure what the path to its value is from the ref....any insight is appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.