React Router Code Reference

If react router is too confusing…

window.history.pushState(“object or string”, “Title”, “/new-url”); to push a new url to the browser.

Thank you to the creators of react router. I believe they make their docs intentionally horrible so that you take their $2000 2 day in person class.

import { Link } from 'react-router';

Goes within your render function

<Link to="/results">
  <button onClick={this.handleFormSubmit.bind(this)} className="form__button form__button--submit">Decide My Night!</button>

import React from "react";
import ReactDOM from "react-dom";

// import components
import Form from "./components/form";
import App from "./components/app2";
import Results from "./components/results";
import GMap from "./components/gmap";

// Import react router deps
import { Router, Route, IndexRoute, browserHistory } from 'react-router';
import { Provider } from 'react-redux';
import store, { history } from './store';

const router = (
  <Provider store={store}>
    <Router history={history}>
      <Route path="/" component={App}>
        <IndexRoute component={Form}></IndexRoute>
        <Route path="/results" component={Results}></Route>


var initialCenter = { lng: -90.1056957, lat: 29.9717272 }

ReactDOM.render(<GMap initialCenter={initialCenter} />, document.getElementById('container'));

Post Content