react-native-calendar-kit
react-native-calendar-kit copied to clipboard
Using CalendarKit can't pass renderHeaderItem because throw error relative to useLocale
When use calendarkit because you need useRef to handle some events, if you try tu customize HeaderItem, it throw error with this message:
"useLocale must be used within a LocaleProvider"
My code is this:
<CalendarKit
ref={refCalendar}
onDateChanged={(date) => {
console.log('onChange');
}}
onLoad={() => {
console.log('onLoad');
}}
events={events}
resources={resources}
initialLocales={initialLocales}
hourWidth={60}
locale={"es"}
firstDay={1}
dayBarHeight={100}
renderEvent={renderEvent}
renderHeaderItem={(item: HeaderItemProps) => {
const dateStr = "20-02-2025";
return (
<ResourceHeaderItem
startUnix={item.startUnix}
resources={item.extra.resources}
renderResource={renderResource}
DateComponent={
<View>
<Text style={{fontSize: 16, fontWeight: 'bold'}}>
{dateStr}
</Text>
</View>
}
/>
);
}}
onPressEvent={(event) => {
router.push(`/partes/${event._id}/update`);
}}
/>
I've been digging and I find that the error is throw in lib/module/context/LocaleProvider.tsx. I can't find why locate is undefined. I hope someone can help me to resolve this.