提交 6f82ceaa 编写于 作者: P Patrick Arminio 提交者: GitHub

Merge pull request #839 from juusaw/ssr-ts-typing

Add typescript definition for ServerStyleSheet
import * as React from "react";
import styled from "..";
import { css, keyframes, ThemeProvider, injectGlobal, withTheme } from "..";
import { css, keyframes, ThemeProvider, injectGlobal, withTheme, ServerStyleSheet } from "..";
// Create a <Title> react component that renders an <h1> which is
// centered, palevioletred and sized at 1.5em
......@@ -155,3 +155,10 @@ const name = "hey";
const ThemedButton = withTheme(MyButton);
<ThemedButton name={name} />;
// server-side rendering styles
const sheet = new ServerStyleSheet();
sheet.collectStyles(<ThemedButton name={name} />)
const styleString = sheet.getStyleTags();
const styleElement = sheet.getStyleElement();
ServerStyleSheet.create();
import * as React from "react";
import { StatelessComponent, ComponentClass, PureComponent } from "react";
import { StatelessComponent, ComponentClass, PureComponent, ReactElement } from "react";
type Component<P> = ComponentClass<P> | StatelessComponent<P>;
......@@ -207,4 +207,11 @@ export function injectGlobal(strings: TemplateStringsArray, ...interpolations: S
export const ThemeProvider: ThemeProviderComponent<any>;
export class ServerStyleSheet {
collectStyles(children: ReactElement<any>): ReactElement<any>
getStyleTags(): string
getStyleElement(): ReactElement<any>[]
static create(): StyleSheet
}
export default styled;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册