question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React native calendars are not rendering as expected with web build especially the custom day Component passed

See original GitHub issue

Please make our job easier by filling this template out to completion. If you’re requesting a feature instead of reporting a bug, please feel free to skip the Environment and Reproducible Demo sections.

Description

I am using react-native-calendars for mobile & web app.When i start project on web its working as expected but when we create build its not showing any style web:: Screenshot 2021-07-09 at 11 12 39 AM

web build::

react-app-rewired build

Screenshot 2021-07-09 at 11 16 11 AM

Have already updated the config-overide file:

  babelInclude([
    path.resolve(__dirname, 'node_modules/react-native-calendars'),
    path.resolve(__dirname, 'node_modules/react-native-swipe-gestures'),
    path.resolve(__dirname, 'src'),
  ])
```,

&& 

…addBabelPlugins( ‘@babel/plugin-proposal-class-properties’, ‘@babel/plugin-transform-modules-commonjs’, ),

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

5reactions
sulaigorcommented, Aug 4, 2021

Version: 1.1264.0 Builder: NextJS

Hi,

I investigated this issue in package source code and I find issue with extractComponentProps (src/component-updater.js) function which is used in Calendar component (src/calendar/index.js) in renderHeader and renderDay methods.

The extractComponentProps function return empty object while component’s (first argument) propTypes are undefined. This empty object is distributed to Day or Header component’s properties so it not set up anything like theme, firstDay etc.

I fix it like this for my build:

function extractComponentProps(component, props, ignoreProps) {
  const componentPropTypes = component.propTypes;
  if (componentPropTypes) {
    const keys = Object.keys(componentPropTypes);
    const componentProps = _.chain(props)
      .pickBy((_value, key) => _.includes(keys, key))
      .omit(ignoreProps)
      .value();
    return componentProps;
  }
  return {...props};
}

I’d rather return copy of props than empty object in my case.

I hope this will help to fix the issue for web building.

Thanks.

1reaction
jamespb97commented, Nov 25, 2021

This also worked for me, also using NextJS to build web version of our project. @sulaigor I’d suggest you make a PR with this code as a fix for this issue 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing state prop in custom day component #1393
I tried implementing a custom day component to override the marking type in the calendar. I followed the documentation related to this, ...
Read more >
react-native-calendar-picker
Calendar Picker Component for React Native. ... If the Chrome debugger is used during development, month shifting may be erratic due to a...
Read more >
Invariant Violation: Objects are not valid as a React child
I was having this error and it turned out to be that I was unintentionally including an Object in my JSX code that...
Read more >
Unit Testing in React: Full Guide on Jest and Enzyme Testing
Discover how to start and proceed with the testing of React components with Enzyme and Jest if you do not have enough experience...
Read more >
5 Easy-to-Use React Native Calendar Libraries | by TC Davis
React Native Calendars does not support Expo Go. However, it can be used with EAS Build and custom clients. React Native Modal Datetime...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found