Skip to content

Commit

PageMain takes the attributes a main and a div share, so the full typecheck passes

syntaqxcommitted Parent7145809Browse files
1 file+2−20/1 viewed
+2−2
1−import { type ComponentProps, createContext, useContext } from "react";
1+import { type HTMLAttributes, createContext, useContext } from "react";
22
33 /** True inside the app shell, whose `<main id="content">` already holds the page. */
44 export const InMain = createContext(false);
77 * A page's main landmark: `<main>` where nothing above is one (signed out),
88 * a plain `<div>` inside the shell, so a page never has two.
99 */
10−export function PageMain(props: ComponentProps<"main">) {
10+export function PageMain(props: HTMLAttributes<HTMLElement>) {
1111 return useContext(InMain) ? <div {...props} /> : <main {...props} />;
1212 }