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

feat: add custom header prop type #2536

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/calendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export interface CalendarProps extends CalendarHeaderProps, DayProps {
/** Style passed to the header */
headerStyle?: StyleProp<ViewStyle>;
/** Allow rendering a totally custom header */
customHeader?: any;
customHeader?: (props: CalendarHeaderProps) => React.ReactNode;
/** Allow selection of dates before minDate or after maxDate */
allowSelectionOutOfRange?: boolean;
}
Expand Down Expand Up @@ -258,8 +258,7 @@ const Calendar = (props: CalendarProps & ContextProp) => {
const renderHeader = () => {
const headerProps = extractHeaderProps(props);
const ref = customHeader ? undefined : header;
const CustomHeader = customHeader;
const HeaderComponent = customHeader ? CustomHeader : CalendarHeader;
const HeaderComponent = customHeader ? customHeader : CalendarHeader;

return (
<HeaderComponent
Expand Down Expand Up @@ -320,6 +319,6 @@ Calendar.propTypes = {
enableSwipeMonths: PropTypes.bool,
disabledByDefault: PropTypes.bool,
headerStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),
customHeader: PropTypes.any,
customHeader: PropTypes.func,
allowSelectionOutOfRange: PropTypes.bool
};
3 changes: 2 additions & 1 deletion src/componentUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {AgendaProps} from './agenda';
import {ReservationListProps} from './agenda/reservation-list';

import {MarkingProps} from './calendar/day/marking';
import {CalendarHeaderProps} from './calendar/header';

const get = require('lodash/get');
const omit = require('lodash/omit');
Expand Down Expand Up @@ -117,7 +118,7 @@ export function extractHeaderProps(props: CalendarProps) {
testID
} = props;

const headerProps = {
const headerProps: CalendarHeaderProps = {
month,
addMonth,
theme,
Expand Down