wix / react-native-calendars

React Native Calendar Components 🗓️ 📆
MIT License
9.5k stars 2.95k forks source link

customHeader prop not working #2236

Open MarcHbb opened 1 year ago

MarcHbb commented 1 year ago

Description

When using customHeader prop, the default header is displayed instead of the custom header

const renderCustomHeader = (params) => ( <Title>MONTH</Title>)

<ExpandableCalendar customHeader={renderCustomHeader} firstDay={1} />

Environment

sleekLancelot commented 7 months ago

Please can someone help with this, passing a function to the customHeader prop like above just give an empty space. passing it as a react component: gives an error. Also on the documentation, the type for customHeader prop is specified as "any", so i can't tell what kind of value that prop expects.

elliothux commented 4 months ago
import { CalendarHeaderProps } from 'react-native-calendars/src/calendar/header';
import { HEADER_HEIGHT } from 'react-native-calendars/src/expandableCalendar/style';

// Header component
function MyHeader(props: CalendarHeaderProps) {
  return (
    <View style={{ height: HEADER_HEIGHT }} className="bg-red-100">
      <Text>Custom header1</Text>
    </View>
  );
}

// Add headerStyle "display: 'none'" or customHeader will not work 
<ExpandableCalendar
  headerStyle={{ display: 'none' }}
  customHeader={MyHeader}
/>