react-slick: Warning: Unknown props `currentSlide`, `slideCount` on tag version 0.14.6
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)
The bug was introduced in this commit https://github.com/akiran/react-slick/commit/436e3052855613a49478382b51743f8bbef9bf15
You added 2 custom props. But 10 lines below you use this object as props for the div
element
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 72
- Comments: 44 (2 by maintainers)
Commits related to this issue
- Fixes #623 — committed to maslianok/react-slick
by maslianok 7 years ago
- updated version with fix to #623 — committed to akiran/react-slick
by akiran 7 years ago
- updated version with fix to #623 — committed to sanbornmedia/react-slick
by akiran 7 years ago
- Update react slick to latest 0.15.4 (#11)
* Alternative fix for #384
* Tiny spelling fix in README.md
* Refactored demos into examples folder
* Expose previous and next function
* add fun... — committed to sky-uk/react-slick
by deleted user 7 years ago
Most upvoted comments
version 0.14.6
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)
The bug was introduced in this commit https://github.com/akiran/react-slick/commit/436e3052855613a49478382b51743f8bbef9bf15
You added 2 custom props. But 10 lines below you use this object as props for the div
element
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 72
- Comments: 44 (2 by maintainers)
Commits related to this issue
- Fixes #623 — committed to maslianok/react-slick by maslianok 7 years ago
- updated version with fix to #623 — committed to akiran/react-slick by akiran 7 years ago
- updated version with fix to #623 — committed to sanbornmedia/react-slick by akiran 7 years ago
- Update react slick to latest 0.15.4 (#11) * Alternative fix for #384 * Tiny spelling fix in README.md * Refactored demos into examples folder * Expose previous and next function * add fun... — committed to sky-uk/react-slick by deleted user 7 years ago
guys, please use ‘add reaction’ -> thumbs up. Don’t pollute issue threads. Plus, each subscriber keeps getting useless emails on each ‘+1’ comment. Thanks for understanding
The current way to solve this (Typescript example, you can import the CustomArrowProps interface from react-slick):
And then in the slider:
nextArrow={<NextArrow />}
This still throws warnings in the console if you use a custom prev and next arrow.
example code:
Downgrading to 0.14.2 works ;~)
Fixed this issue in 0.14.6
Same for me in version 0.23.1 still getting warnings of currentSlide and slideCount.
I’m seeing the same:
All I did was try to use the example. I’m using server rendering although by reading this comment list it looks like the issue is known and has a PR fix waiting.
btw, I’m having this error with buttons too.
Warning: Unknown props
currentSlide,
slideCounton <button> tag
What’s the point with this fix? It changes your component style if you give the className and the style prop to the custom arrow. I find it really inconvenient. If I want a custom component, it’s exactly to avoid the default styling.
+1
I think this issue should be reopened. Passing custom icon will always throw an error
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.
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:
I created this follow-up ticket: https://github.com/akiran/react-slick/issues/671
+1 rolled back to 0.14.5, works fine
+1
+1
I don’t think the problem is with spread at all… HTML Elements shouldn’t have these custom props. From the docs:
@maslianok, add “transform-object-rest-spread” plugin to .babelrc file
getting this error with latest version ,was there a fix?
I’ve updated the PR.
rest
operator is replaced withObject.assign
.transform-object-rest-spread
According to the description, the plugin is not intended to solve
react unkown props
problem.@aiduryagin it doesn’t help
@cheeZery If its so simple, feel free to open a PR. I’m sure they would appreciate the help.
Getting the same issue, please let me know once it gets fixed. (Subscribed)
It also repro in version 0.23.1
@shadrech I also still get the same warning. And as far as I can see the problem was never fixed. In https://github.com/akiran/react-slick/blame/master/src/arrows.js#L73 the given nextArrow and prevArrow components are cloned with the customProps object, which contain the props in question, currentSlide + slideCount. So everytime you want to use a custom arrow, react-slick will try to add currentSlide and slideCount to that component, may it be a button, or a div. And these non-standard props are obviously not known, hence the warning. Please correct me if I’m wrong! 😃