react-expand
Advanced tools
Comparing version 2.6.0 to 2.7.0
/// <reference types="react" /> | ||
import * as React from "react"; | ||
import * as PropTypes from "prop-types"; | ||
import { ModalProps } from "./ModalProps"; | ||
import { ExpandContext } from "../ExpandController"; | ||
import { ModalProps } from "./ModalProps"; | ||
export declare class Modal extends React.Component<ModalProps> { | ||
@@ -7,0 +7,0 @@ static readonly contextTypes: { |
@@ -7,3 +7,4 @@ export * from "./Components/Tabs"; | ||
export * from "./Components/ExpandControl"; | ||
export * from "./Components/StaticContainer"; | ||
export * from "./Components/ExpandController"; | ||
export * from "./Components/ControlledExpandElement"; |
{ | ||
"name": "react-expand", | ||
"version": "2.6.0", | ||
"version": "2.7.0", | ||
"description": "Simple element expand state controlling", | ||
@@ -36,2 +36,3 @@ "main": "build/index.js", | ||
"@types/react": "^16.0.31", | ||
"@types/react-dom": "^16.0.5", | ||
"@types/sinon": "^2.3.3", | ||
@@ -38,0 +39,0 @@ "awesome-typescript-loader": "^3.2.2", |
@@ -17,3 +17,3 @@ # React Expand | ||
Controlling expand state | ||
```jsx | ||
```tsx | ||
import * as React from "react"; | ||
@@ -335,1 +335,40 @@ | ||
``` | ||
### Server-side render | ||
Because `ReactDOM.createPortal` does not support SSR, you must modify code for correct work of `<Modal/>` component | ||
Client side | ||
```jsx | ||
export class Layout extends React.Component { | ||
public render(): React.ReactNode { | ||
return ( | ||
<ExpandController> | ||
<Modal modalId="some-id" defaultOpened> | ||
... | ||
</Modal> | ||
</ExpandController> | ||
); | ||
} | ||
} | ||
``` | ||
Server side | ||
```tsx | ||
app.get("*", (request, response) => { | ||
ReactDOMServer.renderToNodeStream( | ||
<html {...htmlAttrs} data-version={version}> | ||
<body className={StaticContainer.childrenLength ? Modal.defaultProps.activeBodyClassName : ""}> | ||
<div id="app"> | ||
<Layout /> | ||
</div> | ||
<div id={ModalContainer.containerId}> | ||
{StaticContainer.renderStatic()} | ||
</div> | ||
</body> | ||
</html> | ||
).pipe(response); | ||
}) | ||
``` | ||
You also can use [`<StaticContainer/>`](src/Components/StaticContainer/StaticContainer.tsx) and [`<OuterContextPorvider/>`](src/Components/StaticContainer/OuterContextProvider.tsx) in your needs. |
Sorry, the diff of this file is too big to display
393832
39
7576
373
39