DocSpace-client/packages/components/calendar/sub-components/days.js

44 lines
1000 B
JavaScript
Raw Normal View History

import React from "react";
import PropTypes from "prop-types";
import Day from "./day";
2021-02-25 12:16:52 +00:00
import { isArrayEqual } from "../../utils/array";
import { StyledDays } from "../styled-calendar";
class Days extends React.Component {
shouldComponentUpdate(nextProps) {
const { optionsDays, size, onDayClick } = this.props;
if (
isArrayEqual(optionsDays, nextProps.optionsDays) &&
size === nextProps.size &&
onDayClick === nextProps.onDayClick
) {
return false;
}
return true;
}
render() {
//console.log("Days render");
const { optionsDays, size, onDayClick } = this.props;
return (
<StyledDays size={size}>
{optionsDays.map((day, index) => {
return (
<Day size={size} key={index} day={day} onDayClick={onDayClick} />
);
})}
</StyledDays>
);
}
}
Days.propTypes = {
optionsDays: PropTypes.array,
size: PropTypes.string,
onDayClick: PropTypes.func,
};
export default Days;