React-slick: Custom arrows issue: Warning: Unknown props `currentSlide`, `slideCount` on <div> tag

Created on 16 Mar 2017  路  6Comments  路  Source: akiran/react-slick

Version: 0.14.7
Related ticket: https://github.com/akiran/react-slick/issues/623

Error:

Warning: Unknown props `currentSlide`, `slideCount` on <div> tag. Remove these props from the element. For details, see https://fb.me/react-unknown-prop
    in div (created by Carousel)
    in PrevArrow (created by InnerSlider)
    in div (created by InnerSlider)
    in InnerSlider (created by Slider)
    in Slider (created by Carousel)

This happens when using the official example for custom arrows: link

Even though the original ticket was for veresion 0.14.6, this is still happening to me in version 0.14.7.

I fixed it by carefully handling the props on the div (only passing it the props that it can receive) used to render the button and worked like a charm.

This way:

class CarouselArrow extends Component {

  render() {
    let style = {
      ...this.props.style,
      display: 'block',
      background: '#d8e4e8',
      'paddingLeft': '6px',
    };

    return (
      <div className={this.props.className}
              onClick={this.props.onClick}
              style={style}>
      </div>
    );
  }
}

Most helpful comment

If you're using lodash you can also omit those two props.

return (
  <div {..._.omit(props, ['currentSlide', 'slideCount'])}>
  </div>
);

Or, with es6:

const { currentSlide, slideCount, ...filteredProps } = props;
return (
  <div {...filteredProps}>
  </div>
);

All 6 comments

Thanks @matiasherranz
Can you open a PR with this example change

+1

+1

If you're using lodash you can also omit those two props.

return (
  <div {..._.omit(props, ['currentSlide', 'slideCount'])}>
  </div>
);

Or, with es6:

const { currentSlide, slideCount, ...filteredProps } = props;
return (
  <div {...filteredProps}>
  </div>
);

Fixed this in master

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jfamousket picture jfamousket  路  3Comments

will88 picture will88  路  3Comments

darkalor picture darkalor  路  4Comments

laveesingh picture laveesingh  路  3Comments

BradyEdgar94 picture BradyEdgar94  路  3Comments