Skip to content

Commit

Permalink
Add default parameters instead of defaultProps to remove console warning
Browse files Browse the repository at this point in the history
  • Loading branch information
gihev72 committed Jun 13, 2024
1 parent 56cc719 commit 75c4d74
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/DateTimePickerModal.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ import DateTimePicker from "@react-native-community/datetimepicker";
const areEqual = (prevProps, nextProps) => {
return (
prevProps.isVisible === nextProps.isVisible &&
prevProps.date.getTime() === nextProps.date.getTime()
prevProps.date?.getTime() === nextProps.date?.getTime()
);
};

const DateTimePickerModal = memo(
({ date, mode, isVisible, onCancel, onConfirm, onHide, ...otherProps }) => {
({
date = new Date(),
mode,
isVisible = false,
onCancel,
onConfirm,
onHide = () => {},
...otherProps
}) => {
const currentDateRef = useRef(date);
const [currentMode, setCurrentMode] = useState(null);

Expand Down Expand Up @@ -72,10 +80,4 @@ DateTimePickerModal.propTypes = {
minimumDate: PropTypes.instanceOf(Date),
};

DateTimePickerModal.defaultProps = {
date: new Date(),
isVisible: false,
onHide: () => {},
};

export { DateTimePickerModal };

0 comments on commit 75c4d74

Please sign in to comment.