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

Using ReactTransitionGroup in React Native #6

Open
mosesoak opened this issue Dec 13, 2016 · 7 comments
Open

Using ReactTransitionGroup in React Native #6

mosesoak opened this issue Dec 13, 2016 · 7 comments

Comments

@mosesoak
Copy link

I've found that I can use ReactTransitionGroup in a React Native app without problems. @yachaka said here facebook/react-native#9321 that it's really slow but I haven't confirmed that yet, it seems to run fine.

This seems like a useful utility that could pretty easily be offered up to the React Native community.

There are only 2 issues holding it up that I found. One is the DOM reliances in the npm package that prevent it from being installed in a standard RN project:

├── UNMET PEER DEPENDENCY react@^15.0.0
├── UNMET PEER DEPENDENCY react-dom@^15.0.0
└─┬ react-transition-group@1.0.0
  └── dom-helpers@3.2.0

npm WARN react-transition-group@1.0.0 requires a peer of react@^15.0.0 but none was installed.
npm WARN react-transition-group@1.0.0 requires a peer of react-dom@^15.0.0 but none was installed.
npm WARN 3rdParty No description
npm WARN 3rdParty No repository field.
npm WARN 3rdParty No README data
npm WARN 3rdParty No license field.

To get around that temporarily I cloned this repo and pasted these files into my project:

screen shot 2016-12-13 at 1 58 29 pm

And secondly the default of 'span' means you need to pass component={View}.

        <ReactTransitionGroup component={View}>
          {this.state.showLogo &&
            <AnimatedLogo key='logo' onPress={this.handleLogoPress}/>
          }
        </ReactTransitionGroup>

Even without solving for the View issue, it would be handy to come up with a way to make this library easily installable for React Native, perhaps just via some npm magic?

@yachaka
Copy link

yachaka commented Dec 13, 2016

@mosesoak You're actually right, it is running fine and I think to my was due to my chrome debugger left open, sadly, it was that dumb. 😄

@mosesoak
Copy link
Author

TransitionGroup provides some much needed transition management functionality.

However, at least with React Native, it requires writing the animations inside each child component. This ends up making animation hard to maintain, and hard to coordinate at the container level.

Maybe that's one reason why Facebook has ended up abandoning this system.

I do think there's value here but I'm trying to find an animation solution that makes it easier to coordinate all the animations on a screen at the container level, even when there are nested components. I will keep searching!

@jquense
Copy link
Collaborator

jquense commented Dec 14, 2016

RTG isn't gonna solve any hard animation concerns in React, its more of a general, generic solution to controlling behavior of components that need to mount/unmount over time.

To the RN concern, it should work jsut fine right now, but you do have to install react-dom and dom-helpers (even tho they won't be used). We could probably publish just the TransitionGroup component as a seperate package as well as the bundle here to avoid that. like react-addons does now.

@faceyspacey
Copy link

you could also just alias react-dom if you're lazy. i.e. alias it to nothing.

https://www.npmjs.com/package/babel-plugin-module-alias

@peterp
Copy link

peterp commented Dec 29, 2017

@jquense I don't think this is true anymore for the 2.0 branch?

@sturmenta
Copy link

There is no support in "react-native": "0.56.0" tested with react-alert which uses RTG.

captura de pantalla 2018-07-25 a la s 01 17 28 a m

@jtomaszewski
Copy link
Contributor

If this is not working in react-native, what's the workaround?

The biggest problem for me is that I'd like to keep my component in the "DOM" (so it's still rendered as it has been), but not update it anymore (e.g. after open prop is switched to false). So that I can do close animation after the parent wants to close and dismount the child.

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

7 participants