react-navi
Version:
A batteries-included router for react.
39 lines (38 loc) • 1.43 kB
TypeScript
import * as React from 'react';
import { Chunk } from 'navi';
import { HashScrollBehavior } from './HashScroll';
export declare function useViewElement(options?: UseViewOptions): React.ReactElement<any> | null;
export interface UseViewOptions {
disableScrolling?: boolean;
hashScrollBehavior?: HashScrollBehavior;
renderHead?: (chunks: Chunk[]) => React.ReactNode;
/**
* The first Chunk that matches this predicate function will be consumed,
* along with all Chunks before it.
*
* By default, looks for a chunk with type === 'view'.
*/
where?: (Chunk: Chunk) => boolean;
}
export interface UseViewResult {
chunks: Chunk[];
connect: (node: React.ReactNode) => React.ReactElement<any>;
content: any;
element: React.ReactElement<any>;
final: boolean;
head: any;
}
export declare function useView({ disableScrolling, hashScrollBehavior, renderHead, where, }?: UseViewOptions): null | UseViewResult;
export interface ViewProps {
disableScrolling?: boolean;
hashScrollBehavior?: HashScrollBehavior;
renderHead?: (chunks: Chunk[]) => React.ReactNode;
/**
* The first Chunk that matches this will be consumed, along with
* all Chunks before it.
*
* By default, looks for a page, a redirect, or a switch with content.
*/
where?: (Chunk: Chunk) => boolean;
}
export declare const View: React.FunctionComponent<ViewProps>;