Skip to content

Instantly share code, notes, and snippets.

@davidascher
Created May 28, 2016 17:48
Show Gist options
  • Select an option

  • Save davidascher/0ace77b39ab183449420f11d52012196 to your computer and use it in GitHub Desktop.

Select an option

Save davidascher/0ace77b39ab183449420f11d52012196 to your computer and use it in GitHub Desktop.
/**
* NotFoundPage
*
* This is the page we show when the user visits a url that doesn't have a route
*/
import React from 'react';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
import Button from 'components/Button';
import H1 from 'components/H1';
export function NotFound(props) {
return (
<article>
<H1>Page not found.</H1>
<Button
handleRoute={function redirect() {
props.changeRoute('/');
}}
>
Home
</Button>
</article>
);
}
NotFound.propTypes = {
changeRoute: React.PropTypes.func,
};
// react-redux stuff
function mapDispatchToProps(dispatch) {
return {
changeRoute: (url) => dispatch(push(url)),
};
}
// Wrap the component to inject dispatch and state into it
export default connect(null, mapDispatchToProps)(NotFound);
@gaearon
Copy link

gaearon commented May 28, 2016

/**
 * NotFoundPage
 *
 * This is the page we show when the user visits a url that doesn't have a route
 */

import React from 'react';
import { browserHistory } from 'react-router';

import Button from 'components/Button';
import H1 from 'components/H1';

export default function NotFound(props) {
  return (
    <article>
      <H1>Page not found.</H1>
      <Button
        handleRoute={function redirect() {
          browserHistory.push('/');
        }}
      >
        Home
      </Button>
    </article>
  );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment