React-day-picker: React warnings in 15.2.0

Created on 4 Jul 2016  路  7Comments  路  Source: gpbl/react-day-picker

After updating to react 15.0.2 i get the following warning:

warning: Unknown props `localeUtils`, `modifiers`, `numberOfMonths`, `captionElement`, `initialMonth`, `fromMonth`, `renderDay`, `enableOutsideDays`, `fixedWeeks`, `reverseMonths`, `weekdayElement`, `navbarElement` on <div> tag.
Remove these props from the element. For details, see https://fb.me/react-unknown-prop

Removing attributes should do the trick
https://github.com/gpbl/react-day-picker/blob/master/src/DayPicker.js#L465

But this would kill user defined attributes as well and break some code, so it would be saver to remove all propTypes from attributes

Most helpful comment

It should be fixed in v2.3.3! Please reopen if needed :) Thanks

All 7 comments

Yeah, all custom props need to be excluded from being passed down to the child

Something like this should do the trick

const customAttributes = {};

Object.keys(attributes).forEach((key) => {
  if (!DayPicker.propTypes.hasOwnProperty(key)) {
    customAttributes[key] = attributes[key];
  }
});

return (
  <div
    {...customAttributes}
    etc
  </div>
);

Thanks! Working on it :)

Thanks @gpbl that you working on it!

It should be fixed in v2.3.3! Please reopen if needed :) Thanks

Wow that was a fast one! :clap:

馃憣

Was this page helpful?
0 / 5 - 0 ratings