question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Providing an Arrows prop causes arrows to not render.

See original GitHub issue

Hi 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:

https://github.com/hipstersmoothie/react-glider/blob/4cb01307c4422eb55a9ed2dea0ea5d18aa6934c1/src/index.tsx#L286

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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinfarrugiacommented, Nov 4, 2021

@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

0reactions
yashvesikarcommented, Nov 4, 2021

Hi @Gamaranto / @pszalko . Thank you for your input.

I have created a pull request to demo multiple sliders and also uses custom arrow elements (string/selectors) instead of the default implementation. The default arrows are removed and the slide may be transitioned using the custom elements. Let me know if this addresses your concern.

We can tackle support for an Element as mentioned in #36 separately.

Hi @kevinfarrugia where can I find the PR that you made for this issue? was this ever merged in? Thanks!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found