React-slick: Custom Next and Prev Props logs warnings to the console.

Created on 22 Mar 2018  路  2Comments  路  Source: akiran/react-slick

The following two warnings occur when using custom elements for the next and prev arrows.

Warning: React does not recognize the `currentSlide` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `currentslide` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
warning.js:33 Warning: React does not recognize the `slideCount` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `slidecount` instead. If you accidentally passed it from a parent component, remove it from the DOM element.

I've defined them as stateless functions as follows:

export const PrevArrow = props => (
  <button type="button" {...props}>
    <PrevIcon />
  </button>
);

export const NextArrow = props => (
  <button type="button" {...props}>
    <NextIcon />
  </button>
);
question

Most helpful comment

@laveesingh - thanks for the answer!

did you mean:

const {currentSlide, slideCount, ...arrowProps} = props
<button {...arrowProps}>

did note them as warnings in the title, and have corrected it in the body.

All 2 comments

First of all, these are warnings, not errors.
The props that are passed to arrow components, contain slideCount and currentSlide custom props. So, if you're gonna define your arrows like this, you might wanna extract those props out first. Something like this should do:

const {currentSlide, slideCount, ...arrowProps} = props
<button {...arrowProps}>

@laveesingh - thanks for the answer!

did you mean:

const {currentSlide, slideCount, ...arrowProps} = props
<button {...arrowProps}>

did note them as warnings in the title, and have corrected it in the body.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eternalsky picture eternalsky  路  3Comments

laveesingh picture laveesingh  路  3Comments

slashwhatever picture slashwhatever  路  3Comments

darkalor picture darkalor  路  4Comments

quarklemotion picture quarklemotion  路  4Comments