Guest User

Untitled

a guest
Oct 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { Redirect } from 'react-router-dom';
  3. import { connect } from 'react-redux';
  4.  
  5. import { getRedirectPath } from './redirectSelectors';
  6. import { resetRedirectState } from './redirectActions';
  7.  
  8. class RedirectContainer extends Component {
  9. render() {
  10. if (this.props.to) {
  11. return <Redirect to={this.props.to} />;
  12. }
  13.  
  14. return null;
  15. }
  16. }
  17.  
  18. const mapStateToProps = state => ({
  19. to: getRedirectPath(state),
  20. });
  21.  
  22. const mapDispatchToProps = {
  23. resetRedirectState,
  24. };
  25.  
  26. export default connect(
  27. mapStateToProps,
  28. mapDispatchToProps
  29. )(RedirectContainer);
Add Comment
Please, Sign In to add comment