Skip to content

Commit

Permalink
[default-layout] Fix router state bug (NotFound component) (#1786)
Browse files Browse the repository at this point in the history
* [default-layout] Fix null bug in NotFound component

* [default-layout] Give padding to NotFound component
  • Loading branch information
skogsmaskin committed Jun 5, 2020
1 parent 7b8cb38 commit 4fbd16f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/@sanity/default-layout/src/components/NotFound.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react'
import {withRouterHOC, StateLink} from 'part:@sanity/base/router'
import {HAS_SPACES} from '../util/spaces'
import styles from './styles/NotFound.css'

export default withRouterHOC(function NotFound(props) {
const router = props.router
const rootState = HAS_SPACES && router.state.space ? {space: router.state.space} : {}
const rootState =
HAS_SPACES && router.state && router.state.space ? {space: router.state.space} : {}
return (
<div>
<div className={styles.root}>
<h2>Page not found</h2>
{props.children}
<StateLink state={rootState}>Go to index</StateLink>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import "part:@sanity/base/theme/variables-style";

.root {
padding: var(--medium-padding);
}

1 comment on commit 4fbd16f

@vercel
Copy link

@vercel vercel bot commented on 4fbd16f Jun 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.