wix / react-native-calendars

React Native Calendar Components 🗓️ 📆
MIT License
9.59k stars 2.96k forks source link

fix: [ExpandableCalendar] setting screenReaderEnabled to true causing error #2477

Open david-mi opened 5 months ago

david-mi commented 5 months ago

The issue

On ExpandableCalendar component, when screenReaderEnabled state is set to true, it causes a "rendered fewer Hooks than expected" error

https://github.com/wix/react-native-calendars/blob/da9b1bd702e1221002d6e30aaf888e350b627b6a/src/expandableCalendar/index.tsx#L128

Demo

RNC-Screen-reader-error

Analysis

Based on this part of react documentation : Never call component functions directly

This error is occuring because some components are called as regular functions instead of JSX :

https://github.com/wix/react-native-calendars/blob/da9b1bd702e1221002d6e30aaf888e350b627b6a/src/expandableCalendar/index.tsx#L610-L617

Suggested Fix

My fix involves few changes by simply converting render functions name to Pascal case, and then calling them as JSX

Demo

scrcpy_xxsxQswVqw