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

React Transition Group in RSK #1599

Closed
ghost opened this issue Apr 13, 2018 · 0 comments
Closed

React Transition Group in RSK #1599

ghost opened this issue Apr 13, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Apr 13, 2018

Hi all,

I'm trying to fade on entry and leave between pages in React in RSK

Inspired by the post Applying React.js CSS Transitions on initial render I did this for the root component loaded by every page:

    import React from 'react';
    import withStyles from 'isomorphic-style-loader/lib/withStyles';
    import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
    import s from './About.less';

    class About extends React.Component {
        constructor(props) {
            super(props);
            this.state = {
                mounted: false,
            };
        }
        componentDidMount = () => {
            this.setState({
                mounted: true,
            });
        };
        render() {
            const child = this.state.mounted ? <h1>Hello world</h1> : null;
    
            return (
                <ReactCSSTransitionGroup
                    transitionName="example"
                    transitionAppear
                    transitionEnterTimeout={500}
                    transitionLeaveTimeout={300}
                >
                    {child}
                </ReactCSSTransitionGroup>
            );
        }
    }
    
    export default withStyles(s)(About);

And in the css I have:

    .example-appear {
      opacity: 0.01;
      transition: opacity 0.5s ease-in;
    }
    
    .example-appear.example-appear-active {
      opacity: 1;
    }

When the component is mounted, the element is shown, but without any entering transition. Am I doing something wrong there? If I add the proper classes, will this fade out before leaving the page?

Thanks!

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

1 participant