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.

Prop type error every time I select a new day

See original GitHub issue

The calendar component renders as expected, the problem is every time I select a new day, I get a lot of errors in the console.

My render function:

  render() {
    var today = new Date();
    var minDate = Number(new Date()) - (24 * 60 * 60 * 1000) * 7;

    return (
      <InfiniteCalendar
        selectedDate={today}
        minDate={minDate}
        keyboardSupport={true}
        onSelect={ date => {
          console.log("DATE", date);
        }}
      />
    );
  }

Every time I click in a new day I get a lot of errors in the console:

warning.js:36 Warning: Failed prop type: Invalid prop `shouldHeaderAnimate` of type `object` supplied to `Header`, expected `boolean`
...
warning.js:36 Warning: Failed prop type: Invalid prop `transitionEnter` of type `object` supplied to `ReactCSSTransitionGroup`, expected `boolean`
...
warning.js:36 Warning: Failed prop type: Invalid prop `transitionLeave` of type `object` supplied to `ReactCSSTransitionGroup`, expected `boolean`.
...
warning.js:36 Warning: Failed prop type: Invalid prop `enter` of type `object` supplied to `ReactCSSTransitionGroupChild`, expected `boolean`.
    in ReactCSSTransitionGroupChild (created by ReactTransitionGroup)
...
warning.js:36 Warning: Failed prop type: Invalid prop `leave` of type `object` supplied to `ReactCSSTransitionGroupChild`, expected `boolean`.
    in ReactCSSTransitionGroupChild (created by ReactTransitionGroup)

Any thoughts how to fix this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
leaficommented, Feb 9, 2017

Hi, please see https://github.com/toggl/react-infinite-calendar/commit/fd1740ca0d8a9bd871e0b10ca6e58f2ec020a1e0 for one possible fix and a little extra commentary.

In effect, one of the things React does related to the creation of synthetic events is it passes more than one parameter to e.g. the onClick event handler.

While the ‘second’ argument was often undefined in one specific version of React, that changed recently. This was triggering the third, optional argument passed to onDaySelect to (sometimes?) be neither null nor undefined, causing a random event-like object to be copied to shouldHeaderAnimate in the component’s state - causing the failed prop type/invalid prop error we’re experiencing here.

I don’t think this fix should result in noticeably slower code than the original… As far as I’m aware fn.bind(blah blah) results in a new result on every call, so React should see them as different every time, so using a lambda (which React can’t test equivalence on)/new inline function (in e.g. commonjs build) will mean React thinks the onClick prop on the li changed whenever the parent is rerendered - no different from before.

Thanks for the messages above - they were extremely helpful in figuring out the issue.

1reaction
xtalxcommented, Jan 18, 2017

I get this as well (the same 5 errors listed by the OP). react-addons-css-transition-group@15.4.2 react-dom@15.4.2 react-infinite-calendar@1.2.2

I noticed that the errors are only generated the first time the the InfiniteCalendar component is mounted.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React eslint error missing in props validation - Stack Overflow
I have the next code, eslint throw: react/prop-types onClickOut; is missing in props ...
Read more >
Warning: Failed prop type: Invalid prop value supplied to ...
I'm having like 25 errors and the whole app is crashing when I'm triying to change the event starting hour. Every time I...
Read more >
How to validate React props using PropTypes - LogRocket Blog
Learn how to validate props with React PropTypes, React's internal mechanism for adding type checking to component props.
Read more >
jest-prop-type-error - npm Package Health Analysis - Snyk
An important project maintenance signal to consider for jest-prop-type-error is that it hasn't seen any new versions released to npm in the past...
Read more >
<input>: The Input (Form Input) element - HTML
The HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety...
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