Skip to content

Instantly share code, notes, and snippets.

@rrfaria
Created May 11, 2018 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rrfaria/bca49fe17190adb2fe78833b89417ee0 to your computer and use it in GitHub Desktop.
Save rrfaria/bca49fe17190adb2fe78833b89417ee0 to your computer and use it in GitHub Desktop.
React redux and Transition Group
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import {
BrowserRouter as Router,
Switch,
Route,
Link,
Redirect
} from 'react-router-dom';
import { ConnectedRouter } from 'react-router-redux';
import {
TranstionGroup,
CSSTransition,
} from 'react-transition-group';
import Header from './components/layout/header';
import Search from './components/search';
import searchList from './components/searchList';
import './App.css';
import store, { history } from './stores';
class App extends Component {
render() {
return (
<Provider store={store}>
<ConnectedRouter history={history}>
<Route render={({ location }) => (
<div className="App">
<Header/>
<main className="App-container">
<Link to="/">Home</Link>
<Link to="/searchlist">SearchList</Link>
<TranstionGroup>
<CSSTransition
key={location.key}
timeout={300}
classNames='searching'
>
<Switch location={location}>
<Route exact path="/" component={Search} />
<Route exact path="/searchlist" component={searchList} />
</Switch>
</CSSTransition>
</TranstionGroup>
</main>
</div>
)} />
</ConnectedRouter>
</Provider>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment