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

Defaultprops warning when using Datepicker #1819

Open
jhoabran opened this issue Jun 12, 2024 · 5 comments
Open

Defaultprops warning when using Datepicker #1819

jhoabran opened this issue Jun 12, 2024 · 5 comments

Comments

@jhoabran
Copy link

jhoabran commented Jun 12, 2024

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
@Valhalla999
Copy link

+1

3 similar comments
@pepeMalpik
Copy link

+1

@adamyodinsky
Copy link

+1

@atifspall
Copy link

+1

@rohith-zysk
Copy link

+1, Also, for Select Component.

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

6 participants