import React from 'react'
import { connect } from 'react-redux'
import { LinkContainer } from 'react-router-bootstrap'
import { Redirect } from 'react-router'
import { Link } from 'react-router-dom'

/**
 * This function creates routing components from the ones imported above
 * that preserve the itinerary search query from the redux state
 * when redirecting the user between the main map and pages such as the My Settings page.
 * Implementers only need to specify the 'to' route and
 * do not need to hook to redux store to retrieve the itinerary search query.
 * @param LinkComponent The link component to enhance.
 * @returns A new component that passes the redux search params to
 *          LinkComponent's 'to' prop.
 */
const connectLink = LinkComponent =>
  ({ children, queryParams, to, ...props }) => (
    <LinkComponent {...props} to={{ pathname: to, search: queryParams }}>
      {children}
    </LinkComponent>
  )

// connect to the redux store
const mapStateToProps = (state, ownProps) => {
  return {
    queryParams: state.router.location.search
  }
}

const mapDispatchToProps = {
}

export default {
  Link: connect(mapStateToProps, mapDispatchToProps)(connectLink(Link)),
  LinkContainer: connect(mapStateToProps, mapDispatchToProps)(connectLink(LinkContainer)),
  Redirect: connect(mapStateToProps, mapDispatchToProps)(connectLink(Redirect))
}

@@ -218,15 +218,20 @@
 ion 
-creates
+enhances the
  rou
@@ -250,22 +250,8 @@
 nts 
-from the ones 
 impo
@@ -268,20 +268,18 @@
 %0A * 
-that
+by
  preserv
 e th
@@ -274,17 +274,19 @@
  preserv
-e
+ing
  the iti
@@ -384,42 +384,137 @@
 and 
-pages such as the My Settings page
+account-related pages,%0A * so that when the user returns to the map, the itinerary that was previously%0A * displayed is shown again
 .%0A *
@@ -655,20 +655,23 @@
  @param 
-Link
+Routing
 Componen
@@ -680,12 +680,15 @@
 The 
-link
+routing
  com
@@ -785,20 +785,27 @@
         
-Link
+the Routing
 Componen
@@ -843,20 +843,23 @@
 tLink = 
-Link
+Routing
 Componen
@@ -917,20 +917,23 @@
  (%0A    %3C
-Link
+Routing
 Componen
@@ -1012,20 +1012,23 @@
 %7D%0A    %3C/
-Link
+Routing
 Componen
@@ -1037,24 +1037,28 @@
 %0A  )%0A%0A//
+ For
  connect
  to the 
@@ -1049,16 +1049,19 @@
  connect
+ing
  to the 
@@ -1215,16 +1215,91 @@
  = %7B%0A%7D%0A%0A
+// Enhance routing components, connect the result to redux,%0A// and export.%0A
 export d

Tweak comments.