Skip to content
This repository has been archived by the owner on Dec 10, 2019. It is now read-only.

Having trouble applying motion-ui-pack to swapping components #72

Open
ajmajma opened this issue Mar 15, 2017 · 5 comments
Open

Having trouble applying motion-ui-pack to swapping components #72

ajmajma opened this issue Mar 15, 2017 · 5 comments

Comments

@ajmajma
Copy link

ajmajma commented Mar 15, 2017

Hello, I am trying to apply your module to add a little animation to my react app here. I have a little function that swaps the child component shown based on a local state variable and I can't seem to get it to work. So I just have -

     <Transition
          component={false}
          measure={false}
          enter={{
            opacity: 1,
          }}
          leave={{
            opacity: 0
          }}>
              {this.renderQuiz(step)}
          </Transition>

inside of my render. The renderQuiz is just a function that has a switch statement that swaps the component shown based on a local component state in this wrapping parent component. For reference, it just looks like so -

renderQuiz(step) {
  switch (step) {
    case 0:
      return (
        <StepZero  key="Step1"/>
      );
    case 1:
      return (
        <StepOne  key="Step2"/>
      );
 ....

The component swap fine but I am seeing no animation, there is about a 1 second pause between these components showing themselves though. I see you are passing style when you render components inside transition so inside I have style={this.props.style} on the outer most div (thinking this might be the problem) but I am still not seeing the animations. Would appreciate any help in fixing this. Thanks!!

@NourSammour
Copy link

@ajmajma did you solve this issue?

@schnubor
Copy link

schnubor commented May 6, 2017

I'm interested in that exact same issue as well.

@nocategory
Copy link

nocategory commented May 17, 2017

Hey, I had the same issue and ended up fixing it by wrapping a div around the component(s). Seems like it will only work with inline JSX using {condition && }. Give it a try and let me know if it helped you. 😄

Edit: Just tried it with a span aswell, and it worked fine so I guess any HTML element wrapping the component would work

@eenagy
Copy link

eenagy commented Jun 12, 2017

I have the exact same problem. Wrapping in a div solves it, though not when using component="div".

@mightym
Copy link

mightym commented Jul 24, 2017

I'm having the same issues. Using something like this:

<div key='a'><FlyOut  orders={this.state.shipped} /></div>

instead of:

<FlyOut key='a'  orders={this.state.shipped} />

works for the component.

Also I'm a bit confused why I need to pass in a key to get it working. Its just a single component. not a array of several components/elements.

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

No branches or pull requests

6 participants