akveo / react-native-ui-kitten

:boom: React Native UI Library based on Eva Design System :new_moon_with_face::sparkles:Dark Mode
https://akveo.github.io/react-native-ui-kitten/
MIT License
10.19k stars 952 forks source link

Defaultprops warning when using Datepicker #1819

Open jhoabran opened 3 weeks ago

jhoabran commented 3 weeks ago

i have a Datepicker throwing the following error: Warning: MeasureElement: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.

import React from "react"
import { View, StyleSheet } from "react-native";
import { Datepicker, Icon, Text, IconElement } from "@ui-kitten/components";

export enum DateInputStatus{
    Basic = "basic",
    Primary = "primary",
    Success = "success",
    Info = "info",
    Warning = "warning",
    Danger = "danger",
    Control = "control",
}

interface DateInputProps {
  date: Date;
  setDate: (Date) => void;
  label?: string;
  status?: DateInputStatus;
  caption?: string;
  placeholder?: string;
}

const CalendarIcon = (props): IconElement => (
  <Icon {...props} name="calendar" />
);

const AlertIcon = (props: any): IconElement => (
  <Icon {...props} name="alert-circle-outline" fill="red" />
);

export const DateInput = ({
  label,
  caption,
  placeholder,
  date,
  setDate,
  status = DateInputStatus.Primary
}: DateInputProps) => {
  const renderCaption = (): React.ReactElement => {
    return (
      <View style={styles.captionContainer}>
        {AlertIcon(styles.captionIcon)}
        <Text style={styles.captionText}>{caption}</Text>
      </View>
    );
  };

  return (
    <Datepicker
      label={label ? label : undefined}
      caption={caption ? renderCaption : undefined}
      placeholder={placeholder ? placeholder : undefined}
      status={status ? status : undefined}
      date={date}
      onSelect={(nextDate) => setDate(nextDate)}
      accessoryRight={CalendarIcon}
    />
  );
};

const styles = StyleSheet.create({
  captionContainer: {
    display: "flex",
    flexDirection: "row",
    alignItems: "center",
  },
  captionText: {
    fontSize: 12,
    fontWeight: "400",
    color: "red",
  },
  captionIcon: {
    width: 15,
    height: 15,
    marginRight: 5,
  },
});

UI Kitten and Eva version

Package Version
@eva-design/eva 2.2.0
@ui-kitten/components 5.3.1