Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid mutating elements React is in charge of #6

Closed
richardscarrott opened this issue Jan 16, 2023 · 1 comment
Closed

Avoid mutating elements React is in charge of #6

richardscarrott opened this issue Jan 16, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@richardscarrott
Copy link
Owner

Although convenient, this was an unwise decision https://github.com/richardscarrott/react-snap-carousel/blob/main/src/use-snap-carousel.tsx#L176 because React can (and will) remove the the className / styles.

May just have to leave snap point rendering down to the <Carousel /> implementor, e.g.

const Carousel = () => {
  const { pages } = useSnapCarousel();
  const snapPointIndexes = new Set(pages.map((page) => page[0]));
  return (
    <ul>
      {items.map((_, i) => <li style={{ scrollSnapAlign: snapPointIndexes.has(i) ? 'start' : '' }}>{i}</li>)}
    </ul>
  );
}

Could expose snapPointIndexes from useSnapCarousel to make it a little easier.

@richardscarrott richardscarrott added the enhancement New feature or request label Jan 17, 2023
@richardscarrott richardscarrott added bug Something isn't working and removed enhancement New feature or request labels Jan 28, 2023
richardscarrott added a commit that referenced this issue Feb 2, 2023
@richardscarrott
Copy link
Owner Author

Fixed in 0.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant