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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

david-mi
Copy link

The issue

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

const [screenReaderEnabled, setScreenReaderEnabled] = useState(false);

Demo

  • On the left, the application with the screen reader enabled
  • One the right, the application without the screen reader

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 :

<Animated.View testID={`${testID}.expandableContainer`} ref={wrapper} style={wrapperStyle} {...panResponder.panHandlers}>
{renderCalendarList()}
{renderWeekCalendar()}
{!hideKnob && renderKnob()}
{!horizontal && renderAnimatedHeader()}
</Animated.View>
)}
</View>

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant