Skip to content

Instantly share code, notes, and snippets.

@gitexec
Created September 21, 2017 22:12
Show Gist options
  • Save gitexec/9cad68fb7da2b3716b1a1d39de50a713 to your computer and use it in GitHub Desktop.
Save gitexec/9cad68fb7da2b3716b1a1d39de50a713 to your computer and use it in GitHub Desktop.
import {
BrowserRouter as Router,
Link,
Route,
Switch,
} from 'react-router-dom';
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import reducers from './Reducers/ReducersContainer';
export class Home extends React.Component<{}, {}>{
render() {
return <h1>Home</h1>;
}
}
export class About extends React.Component<{}, {}>{
render() {
return <h1>About</h1>;
}
}
const createStoreWithMiddleware = applyMiddleware()(createStore);
ReactDOM.render(
<Provider store={createStoreWithMiddleware(reducers)}>
<Router>
<div>
<Link to="/">Home</Link>{' '}
<Link to={{ pathname: '/about' }}>About</Link>{' '}
<Switch>
<Route path="/" component={Home} />
<Route path="/about" component={About} />
</Switch>
</div>
</Router>
</Provider>,
document.getElementById("react-root")
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment