react-transition-group Миграция с версии 1 на 4.3.0 пример
Primary tabs
В моем случае было:
import React from 'react';
import { connect } from 'react-redux';
import { CSSTransitionGroup } from 'react-transition-group';
import { allSelector } from '../../actions/notifications';
import Notification from './notification';
import '../../../../css/app.css'
class Notifications extends React.Component {
render() {
return (
<CSSTransitionGroup
component="div"
className="notifications"
transitionName="notification-animation"
transitionEnterTimeout={150}
transitionLeaveTimeout={50}>
{this.props.notifications.map(notification => (
<Notification
notification={notification}
key={notification.id}
delay={5000}
/>
))}
</CSSTransitionGroup>
);
}
}
const mapStateToProps = state => ({
notifications: allSelector(state)
});
export default connect(mapStateToProps)(Notifications);
стало:
import React from 'react';
import { connect } from 'react-redux';
import { TransitionGroup, CSSTransition } from 'react-transition-group';
import { allSelector } from '../../actions/notifications';
import Notification from './notification';
import '../../../../css/app.css'
class Notifications extends React.Component {
render() {
return (
<div className="notifications">
<TransitionGroup>
{this.props.notifications.map(notification => (
<CSSTransition
key={notification.id}
component="div"
className="notifications"
classNames="notification-animation"
timeout={{ enter: 150, exit: 50 }}
>
<Notification
notification={notification}
delay={5000}
/>
</CSSTransition>
))}
</TransitionGroup>
</div>
);
}
}
const mapStateToProps = state => ({
notifications: allSelector(state)
});
export default connect(mapStateToProps)(Notifications);
- Документация по миграции: https://github.com/reactjs/react-transition-group/blob/HEAD/Migration.md
- Log in to post comments
- 1638 reads