Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react native calender date picker

import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View
} from 'react-native';
import CalendarPicker from 'react-native-calendar-picker';

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      selectedStartDate: null,
    };
    this.onDateChange = this.onDateChange.bind(this);
  }

  onDateChange(date) {
    this.setState({
      selectedStartDate: date,
    });
  }
  render() {
    const { selectedStartDate } = this.state;
    const startDate = selectedStartDate ? selectedStartDate.toString() : '';
    return (
      <View style={styles.container}>
        <CalendarPicker
          onDateChange={this.onDateChange}
        />

        <View>
          <Text>SELECTED DATE:{ startDate }</Text>
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#FFFFFF',
    marginTop: 100,
  },
});
Comment

react native calender date picker

//Prerequisits
/*
	1. expo install react-native-calendar-picker or yarn add react-native-calendar-picker
    2. yarn add moment //required
*/

//Example

import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View
} from 'react-native';
import CalendarPicker from 'react-native-calendar-picker';

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      selectedStartDate: null,
    };
    this.onDateChange = this.onDateChange.bind(this);
  }

  onDateChange(date) {
    this.setState({
      selectedStartDate: date,
    });
  }
  render() {
    const { selectedStartDate } = this.state;
    const startDate = selectedStartDate ? selectedStartDate.toString() : '';
    return (
      <View style={styles.container}>
        <CalendarPicker
          onDateChange={this.onDateChange}
        />

        <View>
          <Text>SELECTED DATE:{ startDate }</Text>
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#FFFFFF',
    marginTop: 100,
  },
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: material ui textfield with chips 
Javascript :: javascript import class 
Javascript :: check if element with class has another class javascript 
Javascript :: vue js get routes 
Javascript :: js html editor 
Javascript :: knex.js migration create 
Javascript :: adding element to array javascript 
Javascript :: remove an element from array javascript 
Javascript :: javascript change _ to space 
Javascript :: is javascript faster than python 
Javascript :: math captcha 
Javascript :: material ui 
Javascript :: how to check if local storage is available 
Javascript :: js remove escape characters from json 
Javascript :: javascript regex One or more occurrences of the pattern 
Javascript :: react get route params 
Javascript :: ejs render 
Javascript :: md5 checksum javascript 
Javascript :: check if array is empty javascript 
Javascript :: parsing json object in java 
Javascript :: tobe a number jest 
Javascript :: mouse position 
Javascript :: array flatten 
Javascript :: js append zeros 
Javascript :: unwind mongodb 
Javascript :: order by mongodb 
Javascript :: react vscode stop auto close tag 
Javascript :: trigger a button click with javascript on the enter key in a text box 
Javascript :: proxy api javascript get 
Javascript :: try catch js 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =