mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
Merge pull request #8621 from evanbb/master
Adding typings for react-helmet
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/// <reference path="react-helmet.d.ts" />
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
import * as React from 'react';
|
||||
import Helmet from 'react-helmet';
|
||||
|
||||
<Helmet title="My Title" />
|
||||
|
||||
const head = Helmet.rewind();
|
||||
const html = `
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
${ head.title.toString() }
|
||||
${ head.meta.toString() }
|
||||
${ head.link.toString() }
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
// React stuff here
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
|
||||
function HTML() {
|
||||
return (
|
||||
<html>
|
||||
<head>
|
||||
{ head.title.toComponent() }
|
||||
{ head.meta.toComponent() }
|
||||
{ head.link.toComponent() }
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
// React stuff here
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
// Type definitions for react-helmet
|
||||
// Project: https://github.com/nfl/react-helmet
|
||||
// Definitions by: Evan Bremer <https://github.com/evanbb>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
declare module 'react-helmet' {
|
||||
import { Component } from 'react';
|
||||
|
||||
interface HelmetProps {
|
||||
title?: string;
|
||||
titleTemplate?: string;
|
||||
base?: any;
|
||||
link?: Array<any>;
|
||||
meta?: Array<any>;
|
||||
script?: Array<any>;
|
||||
onChangeClientState?: (newState: any) => void;
|
||||
}
|
||||
|
||||
interface HelmetData {
|
||||
title: HelmetDatum;
|
||||
base: HelmetDatum;
|
||||
link: HelmetDatum;
|
||||
meta: HelmetDatum;
|
||||
script: HelmetDatum;
|
||||
}
|
||||
|
||||
interface HelmetDatum {
|
||||
toString(): string;
|
||||
toComponent(): Component<any, any>;
|
||||
}
|
||||
|
||||
class Helmet extends Component<HelmetProps, any> {
|
||||
static rewind(): HelmetData
|
||||
}
|
||||
|
||||
export default Helmet;
|
||||
}
|
||||
Reference in New Issue
Block a user