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

Duplicated elements when using Motion component #583

Open
abohannon opened this issue Dec 30, 2019 · 1 comment
Open

Duplicated elements when using Motion component #583

abohannon opened this issue Dec 30, 2019 · 1 comment

Comments

@abohannon
Copy link

We're using Motion in an image slider and all slides are duplicated when changing slides.
Here's a screenshot after interacting with the slider a few times. The slider starts with 5 slides wrapped in Motion components.

Screen Shot 2019-12-30 at 11 35 53 AM

Here's the implementation:

{items.map(
          ({ image, content, style, defaultStyle, imageClass }, index) => (
            <Motion
              key={image}
              defaultStyle={getDefaultStyle(index)}
              style={style}
            >
              {style => {
                return (
                  <div
                    style={{
                      transform: `translateX(${style.x}vw)`,
                      height: slideHeight,
                      maxHeight: slideHeight,
                    }}
                    className={classNames(
                      'carouselSlide',
                      classes.carouselSlide,
                    )}
                  >
                    <img
                      alt={image}
                      src={image}
                      className={classNames(imageClass, classes.image)}
                    />
                  </div>
                )
              }}
            </Motion>
          ),
        )}
@nkbt
Copy link
Collaborator

nkbt commented Dec 30, 2019

console.log(items)

There is smth to do with how you change items. Motion does nothing to duplicate elements

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

No branches or pull requests

2 participants