Skip to content

Renderprops components are not animating in 9 beta. #743

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

Closed
QuietNoise opened this issue Jul 4, 2019 · 3 comments
Closed

Renderprops components are not animating in 9 beta. #743

QuietNoise opened this issue Jul 4, 2019 · 3 comments
Labels
kind: bug Something isn't working

Comments

@QuietNoise
Copy link

QuietNoise commented Jul 4, 2019

🐛 Bug Report

When you use Transition, Trail, Spring components (and possibly others too) with React Spring 9 beta to animate DOM elements the animations are not applied (DOM elements do not have the style attribute applied).

To Reproduce

  1. Wrap an element to animate with a Transition component and appropriate arguments for animation. Apply animation arguments to the style attribute of the element to animate. For example:
<Transition
        items={show}
        from={{ opacity: 0 }}
        enter={{ opacity: 1 }}
        leave={{ opacity: 0 }}
      >
        {show => show &&
          (props => (
            <div style={props}>
              <span role="img" aria-label="peace">✌</span>
            </div>
          ))
        }
</Transition>
  1. In you app generate event that will negate value of the 'show' variable.
  2. Observe the DOM element being removed/added with delay but without style attribute applied and thus without animations.
    2019-07-05_00h45_09

Expected behavior

I would expect the style attribute to be applied in a same way it works in version 8.
2019-07-05_00h47_10

Link to repro (highly encouraged)

Bug example with v9.beta.31
https://codesandbox.io/s/transition-in-beta-odwx2
When you click on the Toggle Visibility button you can see the peace emoji is not animated.

Exact same example but with v.8.0.27, works as expected.
https://codesandbox.io/s/transition-in-stable-zifvq

Environment

  • react-spring v9.beta.31
  • react v16.8.6
@QuietNoise QuietNoise added the kind: bug Something isn't working label Jul 4, 2019
@QuietNoise
Copy link
Author

Inspired by @aleclarson 's comment #738 (comment) to another issue, I wrapped the div component with animated factory and animations are now working as expected.

<Transition
        items={showOrNot}
        from={{ opacity: 0 }}
        enter={{ opacity: 1 }}
        leave={{ opacity: 0 }}
      >
        {show =>
          show &&
          (props => (
            <animated.div style={props}>
              <span role="img" aria-label="peace">
                ✌
              </span>
            </animated.div>
          ))
        }
</Transition>

Updated working sandbox: https://codesandbox.io/s/transition-in-beta-with-animated-factory-5ppzk
Probably can close this particular issue?

I shall mention that the necessity to wrap components with animated factory is not mentioned anywhere in the manual about Render-props API i.e. in here https://www.react-spring.io/docs/props/transition animated factory is not used in quoted code snippets. It's also worth mentioning that everything works without animated factory in v.8 of the react-spring library.

@aleclarson
Copy link
Contributor

aleclarson commented Jul 8, 2019

In v8, the renderprops API re-renders its children on every animation frame. In v9, since the renderprops API now runs on top of the hooks API, you need to use animated.div instead of a plain div. I'll be sure to update the docs about this before releasing v9. Thanks! 👍

@mario-jerkovic
Copy link

Inspired by @aleclarson 's comment #738 (comment) to another issue, I wrapped the div component with animated factory and animations are now working as expected.

<Transition
        items={showOrNot}
        from={{ opacity: 0 }}
        enter={{ opacity: 1 }}
        leave={{ opacity: 0 }}
      >
        {show =>
          show &&
          (props => (
            <animated.div style={props}>
              <span role="img" aria-label="peace">
                ✌
              </span>
            </animated.div>
          ))
        }
</Transition>

Updated working sandbox: https://codesandbox.io/s/transition-in-beta-with-animated-factory-5ppzk
Probably can close this particular issue?

I shall mention that the necessity to wrap components with animated factory is not mentioned anywhere in the manual about Render-props API i.e. in here https://www.react-spring.io/docs/props/transition animated factory is not used in quoted code snippets. It's also worth mentioning that everything works without animated factory in v.8 of the react-spring library.

This "working" example is still not working, event with the latest rc.

cameron-martin pushed a commit to cameron-martin/react-spring that referenced this issue May 10, 2022
* Support for min/max in the TimeScale.

* Min/max take same format as input data

If the input data is formatted and the format property of the scale is set - exp. '%Y-%m-%d' - the min/max properties provided explicitly were not taken into account. Instead the actual range was used - this was crashing as the values `values.max` and `values.min` are already converted to native format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants