mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 19:51:53 +00:00
Add NextStatelessComponent interface
This commit is contained in:
Vendored
+6
@@ -3,6 +3,7 @@
|
||||
// Definitions by: Drew Hays <https://github.com/dru89>
|
||||
// Brice BERNARD <https://github.com/brikou>
|
||||
// James Hegedus <https://github.com/jthegedus>
|
||||
// Resi Respati <https://github.com/resir014>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
@@ -39,6 +40,11 @@ declare namespace next {
|
||||
}
|
||||
}
|
||||
|
||||
type NextSFC<P = {}> = NextStatelessComponent<P>;
|
||||
interface NextStatelessComponent<P = {}> extends React.StatelessComponent<P> {
|
||||
getInitialProps?: (ctx: NextContext) => Promise<any>;
|
||||
}
|
||||
|
||||
type UrlLike = url.UrlObject | url.Url;
|
||||
|
||||
interface ServerConfig {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import * as React from "react";
|
||||
import { NextStatelessComponent } from "next";
|
||||
|
||||
interface NextComponentProps {
|
||||
example: string
|
||||
}
|
||||
|
||||
class ClassNext extends React.Component<NextComponentProps> {
|
||||
async getInitialProps() {
|
||||
return { example: 'example' }
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>I'm a stateless component! {this.props.example}</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const StatelessNext: NextStatelessComponent<NextComponentProps> = ({ example }) => (
|
||||
<div>I'm a stateless component! {example}</div>
|
||||
)
|
||||
|
||||
StatelessNext.getInitialProps = async () => {
|
||||
return { example: 'example' }
|
||||
}
|
||||
@@ -33,6 +33,7 @@
|
||||
"test/next-document-tests.tsx",
|
||||
"test/next-link-tests.tsx",
|
||||
"test/next-dynamic-tests.tsx",
|
||||
"test/next-router-tests.tsx"
|
||||
"test/next-router-tests.tsx",
|
||||
"test/next-component-tests.tsx"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user