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

fix: calculates slide width on first pass #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JarrodMFlesch
Copy link
Contributor

Calculates the slide width outside of the effect, so context has the correct slide width on the first pass.

const memoizedSlideWidth = useMemo(() => {
return `${(slidesToShow > 1 ? 1 / slidesToShow : slidesToShow) * 100}%`
}, [slidesToShow]);

Copy link

@adiba adiba Apr 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to memoize. We can just write const slideWidth = `...`;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may want to keep the slider widths uninitialized, see my comment here: #17 (comment)

Copy link
Contributor Author

@JarrodMFlesch JarrodMFlesch Apr 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the benefit of waiting a render cycle to provide known information via context?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants