Skip to content

Commit

Permalink
fix: avoid janky re-renders when navigating from / (#44)
Browse files Browse the repository at this point in the history
The /spaces layout added a `<section>` parent element which caused react
to have to trash the entire tree and rebuild, which was janky

removing it means the dom is stable and navigating is buttery. ✨



License: MIT

---------

Signed-off-by: Oli Evans <oli@protocol.ai>
  • Loading branch information
olizilla authored Nov 15, 2023
1 parent 2865d06 commit 1b428c4
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 85 deletions.
35 changes: 0 additions & 35 deletions src/app/docs/page.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import SidebarLayout from '@/components/SidebarLayout'
import './globals.css'
import type { Metadata } from 'next'
import { H2 } from '@/components/Text'
import Link from 'next/link'

export const metadata: Metadata = {
title: 'w3up console',
Expand All @@ -18,9 +16,6 @@ export default function RootLayout ({
<html lang="en">
<body className='bg-grad min-h-screen'>
<SidebarLayout>
{/* <H2 explain='a decentralised bucket identified by a DID'>
<Link href='/'>Space</Link>
</H2> */}
{children}
</SidebarLayout>
</body>
Expand Down
8 changes: 3 additions & 5 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ export default function SpacePage (): JSX.Element {
return (
<>
<SpacesNav />
<div>
<H2>Pick a Space</H2>
<div className='max-w-lg border rounded-md border-zinc-700'>
{ spaces.map(s => <Item space={s} key={s.did()} /> ) }
</div>
<H2>Pick a Space</H2>
<div className='max-w-lg border rounded-md border-zinc-700'>
{ spaces.map(s => <Item space={s} key={s.did()} /> ) }
</div>
</>
)
Expand Down
2 changes: 1 addition & 1 deletion src/app/space/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default function CreateSpacePage (): JSX.Element {
return (
<>
<SpacesNav />
<H2>Create a new Space</H2>
<div className='max-w-xl'>
<H2>Create a new Space</H2>
<SpaceCreatorForm />
</div>
<div className='mt-12 max-w-xl text-sm leading-6'>
Expand Down
9 changes: 2 additions & 7 deletions src/app/space/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ interface LayoutProps extends PropsWithChildren {

export default function Layout ({children}: LayoutProps): JSX.Element {
return (
<section>
<>
{children}
</section>
</>
)
}

Expand All @@ -23,11 +23,6 @@ export default function Layout ({children}: LayoutProps): JSX.Element {
export function SpacesNav () {
return (
<>
{/* <div style={{minHeight: 68}}>
<p className='font-normal pt-4'>
Pick a space to see what's in it, or create a new one.
</p>
</div> */}
<div className='lg:flex items-center place-items-center justify-between mt-2 mb-8'>
<div className='lg:w-2/6 order-last'>
<UsageBar />
Expand Down
32 changes: 0 additions & 32 deletions src/app/terms/page.tsx

This file was deleted.

0 comments on commit 1b428c4

Please sign in to comment.