mohammad-goldast / React-native-jalali-date-picker

A simple and clean jalali datepicker for ReactNative
20 stars 8 forks source link

Error undefined #1

Open ali464sh opened 6 years ago

ali464sh commented 6 years ago

TypeError: undefined is not an object (evaluating 'this.props.day.toString') My Commponent

import React from 'react';

import { Dimensions,Text, View } from 'react-native'; import PersianCalendarPicker from 'react-native-jalali-date-picker';

export default class FreeTime extends React.Component { constructor(props) { super(props);

        this.state = {
            date: new Date(),
            prevDay: (d => new Date(d.setDate(d.getDate() - 1)))(new Date()),
            prevDays: (d => new Date(d.setDate(d.getDate() - 1)).toJSON().split('T')[0].replace(/-/g, ''))(new Date()),
        };
        this.onDateChange = this.onDateChange.bind(this);
    }

    onDateChange(date) {
    this.setState({ date });
    }

    render() {
        const { date, prevDay, prevDays } = this.state;
        return (
            <View style={styles.container}>
                <PersianCalendarPicker
                    selectedDate={date}
                    onDateChange={this.onDateChange}
                    screenWidth={Dimensions.get('window').width}
                    minDate={prevDay}
                    prevDays={prevDays}
                />
            <Text style={styles.selectedDate}> Date: { this.state.date.toString() } </Text>
        </View>
        );
    }
}
mohammad-goldast commented 6 years ago

Thank you for report this issue. I will fix all the issues soon.

hamidkhosravian commented 6 years ago

hi @blackhair did you can fix this issue?

mgolkardev commented 6 years ago

Hi

Main in package.json set Day.js, you can use it directly.

import PersianCalendarPicker from 'react-native-jalali-date-picker/PersianCalendarPicker';

Or use my version:

https://github.com/mgolkardev/react-native-jalali-date-picker-rtl