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

Question regarding a crash in a simple example #301

Closed
fellenabmb opened this issue Jul 7, 2023 · 1 comment
Closed

Question regarding a crash in a simple example #301

fellenabmb opened this issue Jul 7, 2023 · 1 comment
Labels
needs repro Needs reproducible example question Further information is requested stale

Comments

@fellenabmb
Copy link

fellenabmb commented Jul 7, 2023

Ask your Question

Simple question, I'm trying to implement the date picker, the single variant, in particular, is crashing with the following error:

Simulator Screenshot - iPhone 14 Pro - 2023-07-07 at 14 35 08

The other variants (input, range, multiple) seem to work just fine replicating the code in the example from the librarie's repository.

The component implementation:


import React, { useCallback, useState } from 'react';
import { DatePickerModal } from 'react-native-paper-dates';

import type { CalendarDate } from 'react-native-paper-dates/lib/typescript/Date/Calendar';
import type { DatePickerProps } from './data-picker-props';

type Props = { date: CalendarDate };

const Single = ({ visible, onDismiss, onConfirm }: DatePickerProps) => {
  const [date, setDate] = useState<CalendarDate>(new Date('2023-07-07T03:24:00'));

  const confirm = useCallback(
    ({ date }: Props) => {
      setDate(date);
      onConfirm(date as CalendarDate);
    },
    [date]
  );

  return (
    <DatePickerModal
      locale="es"
      mode="single"
      visible={visible}
      onDismiss={onDismiss}
      onConfirm={confirm}
      date={date}
    />
  );
};

export default Single;

The example screen:

import registerTranslation from '@objects/data-picker-registerTranslation';
import React, { useState } from 'react';
import { StyleSheet } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import DatePicker from '../components/ui/atoms/data-picker/data-picker-single';
import { Button } from '@components/ui';

const styles = StyleSheet.create({
  container: { justifyContent: 'center' }
});

const RNDatePicker = () => {
  const [visible, setVisible] = useState(false);
  registerTranslation;

  return (
    <SafeAreaView style={styles.container}>
      <Button onPress={() => setVisible(true)}>show date picker</Button>
      <DatePicker
        visible={visible}
        onDismiss={() => setVisible(false)}
        onConfirm={date => alert(date)}
      />
    </SafeAreaView>
  );
};

export default RNDatePicker;

Am I missing something? 🤔

My setup:
Macbook M1, running MacOS 13.4
Xcode 14.3
"react": "18.2.0",
"react-native": "0.71.8",

@fellenabmb fellenabmb added the question Further information is requested label Jul 7, 2023
@iM-GeeKy iM-GeeKy added the needs repro Needs reproducible example label Jul 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2023

Hey! Thanks for opening the issue. Can you provide a minimal repro which demonstrates the issue? Posting a snippet of your code in the issue is useful, but it's not usually straightforward to run. A repro will help us debug the issue faster. Please try to keep the repro as small as possible. The easiest way to provide a repro is on snack.expo.dev. If it's not possible to repro it on snack.expo.dev, then you can also provide the repro in a GitHub repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Needs reproducible example question Further information is requested stale
Projects
None yet
Development

No branches or pull requests

2 participants