Providing an Arrows prop causes arrows to not render.
See original GitHub issueHi there, first of all, thanks for this awesome integration!
I think I’ve found an issue with the arrows
prop, when supplying the prop, the arrows won’t render. This is especially problematic when working with different gliders on the same page, since they all need distinct arrow selectors.
I think this is the line that’s causing arrows to not render:
As a workaround I’m running a useLayoutEffect
and adding the arrows manually:
// your arrow selector / elements here
React.useLayoutEffect(() => {
if (gliderRef.current && arrows) {
const { prev: prevArrow, next: nextArrow } = arrows
const container = gliderRef.current.ele.parentElement
if (container) {
container.insertBefore(prevArrow, gliderRef.current.ele)
container.appendChild(nextArrow)
}
}
}, [arrows])
Let me know if this is expected behaviour or actually a bug. If so, I can attempt a PR that also takes care of #36
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Why Arrow Functions and bind in React's Render are ...
Here's why: The parent component is passing down an arrow function on props. Arrow functions are reallocated on every render (same story with ......
Read more >Why shouldn't JSX props use arrow functions or bind?
Using arrow functions or binding in JSX is a bad practice that hurts performance, because the function is recreated on each render.
Read more >Why Arrow Functions and bind in React's Render ... - Medium
Watch for arrows… In a previous post, I explained how to extract React child components to avoid using bind or arrow functions in...
Read more >When should I use arrow functions with React?
When used incorrectly, arrow functions cause performance issues. ... Arrow functions don't redefine the value of this within their function ...
Read more >eslint-plugin-react/jsx-no-bind.md at master - GitHub
A bind call or arrow function in a JSX prop will create a brand new function on every single render. This is bad...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@yashvesikar I was unable to replicate the issue, but I have updated Storybook to include a demo includes a slider which uses the
arrows
prop. This was done in #67 .Demo: https://hipstersmoothie.github.io/react-glider/?path=/story/glider--multiple-gliders
Hi @kevinfarrugia where can I find the PR that you made for this issue? was this ever merged in? Thanks!