Skip to content

TransitionGroup persists components assigned to leave #4205

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
sher opened this issue Jun 24, 2015 · 3 comments
Closed

TransitionGroup persists components assigned to leave #4205

sher opened this issue Jun 24, 2015 · 3 comments

Comments

@sher
Copy link

sher commented Jun 24, 2015

Below is the sample where you have a list of items, one of which can be active. Maybe I'm misusing it, but TransitionGroup keeps the item that should have been replaced.

http://jsbin.com/bonoyibahe/edit?js,output

var ReactTransitionGroup = React.addons.TransitionGroup;

var Active = React.createClass({
  render: function () {
    return <li>Active</li>;
  }
});

var Inactive = React.createClass({
  handleClick: function (e) {
    e.preventDefault();
    this.props.activateItem(this.props.id);
  },

  render: function () {
    return <li><a href='#' onClick={this.handleClick}>Inactive: click to activate</a></li>;
  }
});

var List = React.createClass({
  getInitialState: function () {
    return {
      activeId: 0
    };
  },

  activateItem: function (id) {
    this.setState({ activeId: id });
  },

  render: function () {

    var items = [];

    for (var i = 0; i < 2; i++) {
      var item = i === this.state.activeId ?
        <Active key={'active' + i} /> :
        <Inactive key={'inactive' + i} id={i} activateItem={this.activateItem} />;
      items.push(item);
    }

    return (
      <ReactTransitionGroup component='ul'>
        { items }
      </ReactTransitionGroup>
    );
  }
});

React.render(<List />, document.body);
@sophiebits
Copy link
Collaborator

Pretty sure this is a bug that's been fixed on master. Works fine if I pull in the latest:

http://jsbin.com/rokazegofe/1/edit?html,js,output

@davidreher
Copy link

when will the fix be released? I ran into the same issue ...

@jimfb
Copy link
Contributor

jimfb commented Jul 8, 2015

@davidreher The 0.14 beta (already released, but in beta) should have this fix. We're working on getting 0.14 ready for a final release; follow the checkmarks: #3220

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

4 participants