DEV Community

loading...

Enter date easily with react-native-datefield

tuantvk profile image tuantvk ・1 min read

react-native-datefield
In the course of implementing a few projects, I have found that users who use the selection date function in applications often have difficulty choosing years in the past.

Hence, I developed the react-native-datefield library to make it easier for the users to enter date data.
The react-native-datefield library has great support in terms of both user interface and functional performance. It validates the entered date data, leap years, allows customization of layout input and returns errors if the user enters incorrect data.

Components:

  • DateMonthYearField
  • MonthDateYearField
  • YearMonthDateField

Usage

import DateField from 'react-native-datefield';
Enter fullscreen mode Exit fullscreen mode

or

const DateField = require('react-native-datefield');
Enter fullscreen mode Exit fullscreen mode
<DateField
  labelDate='Enter date'
  labelMonth='Enter month'
  labelYear='Enter year'
  defaultValue={new Date()}
  styleInput={styles.inputBorder}
  onSubmit={(value) => console.log(value)}
/>

<MonthDateYearField
  styleInput={styles.inputBorder}
  onSubmit={(value) => console.log('MonthDateYearField', value)}
/>

<YearMonthDateField
  styleInput={styles.inputBorder}
  onSubmit={(value) => console.log('YearMonthDateField', value)}
/>

const styles = StyleSheet.create({
  inputBorder: {
    width: '30%',
    borderRadius: 8,
    borderColor: '#cacaca',
    borderWidth: 1,
    marginBottom: 20,
  },
});
Enter fullscreen mode Exit fullscreen mode

View more example App.tsx.

My repo on Github react-native-datefield

Thanks for reading !

Discussion (0)

Forem Open with the Forem app