mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #32961 from joaovieira/next/v8-compat
[@types/next] Remove buildManifest from renderPage for Next.js 8.
This commit is contained in:
Vendored
+9
-4
@@ -2,10 +2,15 @@ import * as React from "react";
|
||||
import { NextContext, NextComponentType } from ".";
|
||||
import { DefaultQuery } from "./router";
|
||||
|
||||
/**
|
||||
* Result from renderPage().
|
||||
* https://github.com/zeit/next.js/blob/v8.0.0/packages/next/pages/_document.js#L18
|
||||
* https://github.com/zeit/next.js/blob/v8.0.0/packages/next-server/server/render.tsx#L159
|
||||
* https://github.com/zeit/next.js/blob/v8.0.0/packages/next-server/server/render.tsx#L44
|
||||
*/
|
||||
export interface RenderPageResponse {
|
||||
buildManifest: Record<string, any>;
|
||||
html?: string;
|
||||
head?: Array<React.ReactElement<any>>;
|
||||
head?: React.ReactNode;
|
||||
}
|
||||
|
||||
export interface PageProps {
|
||||
@@ -31,7 +36,7 @@ export interface NextDocumentContext<Q extends DefaultQuery = DefaultQuery> exte
|
||||
E extends PageProps = AnyPageProps,
|
||||
P = E,
|
||||
EA extends PageProps = AnyPageProps,
|
||||
PA = EA,
|
||||
PA = EA
|
||||
>(
|
||||
enhancer?:
|
||||
| Enhancer<E, P> // tslint:disable-line no-unnecessary-generics
|
||||
@@ -44,7 +49,7 @@ export interface NextDocumentContext<Q extends DefaultQuery = DefaultQuery> exte
|
||||
* https://github.com/zeit/next.js/blob/7.0.0/server/document.js#L16
|
||||
*/
|
||||
export interface DefaultDocumentIProps extends RenderPageResponse {
|
||||
styles?: React.ReactNode[];
|
||||
styles?: React.ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for next 7.0
|
||||
// Type definitions for next 8.0
|
||||
// Project: https://github.com/zeit/next.js/packages/next
|
||||
// Definitions by: Drew Hays <https://github.com/dru89>
|
||||
// Brice BERNARD <https://github.com/brikou>
|
||||
|
||||
@@ -48,19 +48,24 @@ class MyDoc extends Document<WithUrlProps> {
|
||||
// with app and component enhancers
|
||||
const enhanceApp: Enhancer<PageProps, {}> = App => props => <App />;
|
||||
const enhanceComponent: Enhancer<PageProps, {}> = Component => props => <Component />;
|
||||
const { html, head, buildManifest } = renderPage({
|
||||
const { html, head } = renderPage({
|
||||
enhanceApp,
|
||||
enhanceComponent
|
||||
});
|
||||
|
||||
const initialProps = await Document.getInitialProps(ctx);
|
||||
|
||||
const styles = [...(initialProps.styles ? initialProps.styles : []), <style />];
|
||||
const styles = (
|
||||
<>
|
||||
{initialProps.styles}
|
||||
<style />
|
||||
</>
|
||||
);
|
||||
|
||||
// Custom prop
|
||||
const url = req!.url;
|
||||
|
||||
return { html, head, buildManifest, styles, url };
|
||||
return { html, head, styles, url };
|
||||
}
|
||||
|
||||
constructor(props: WithUrlProps & DocumentProps) {
|
||||
@@ -73,12 +78,14 @@ class MyDoc extends Document<WithUrlProps> {
|
||||
|
||||
render() {
|
||||
const { pathname, query } = this.props.__NEXT_DATA__;
|
||||
const { head, styles } = this.props;
|
||||
|
||||
return (
|
||||
<html>
|
||||
<Head nonce="nonce" any="property" should="work" here>
|
||||
{head}
|
||||
<title>My page</title>
|
||||
{this.props.styles}
|
||||
{styles}
|
||||
</Head>
|
||||
<body>
|
||||
<Main />
|
||||
|
||||
Reference in New Issue
Block a user