Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error undefined #1

Open
ali464sh opened this issue May 13, 2018 · 3 comments
Open

Error undefined #1

ali464sh opened this issue May 13, 2018 · 3 comments

Comments

@ali464sh
Copy link

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
Copy link
Owner

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

@hamidkhosravian
Copy link

hi
@BlackHair did you can fix this issue?

@mgolkardev
Copy link

mgolkardev commented Aug 28, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants