Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Don't SSR example editor on website. #2356

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@docusaurus/core": "^2.0.0-alpha.36",
"@docusaurus/preset-classic": "^2.0.0-alpha.36",
"classnames": "^2.2.6",
"draft-js": "^0.11.3",
"draft-js": "^0.11.4",
"react": "^16.10.2",
"react-dom": "^16.10.2"
},
Expand Down
32 changes: 21 additions & 11 deletions website/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ import classnames from 'classnames';
import DraftEditorExample from '../components/DraftEditorExample';
import styles from './styles.module.css';

/** Won't render children on server */
function ClientOnly({children, fallback}) {
if (typeof window === 'undefined') {
return fallback || null;
}
return children;
}

function Home() {
const context = useDocusaurusContext();
const {siteConfig = {}} = context;
Expand Down Expand Up @@ -74,9 +82,9 @@ function Home() {
target="_blank"
rel="noreferrer noopener">
immutable-js
</a>, offering an API with functional state updates and
aggressively leveraging data persistence for scalable memory
usage.
</a>
, offering an API with functional state updates and aggressively
leveraging data persistence for scalable memory usage.
</p>
</div>
</div>
Expand All @@ -87,15 +95,17 @@ function Home() {
'margin-vert--xl',
styles.hideOnTabletAndSmaller,
)}>
<div className="col col--6 col--offset-3">
<h2>Try it out!</h2>
<p>
Here's a simple example of a rich text editor built in Draft.js.
</p>
<div id="rich-example">
<DraftEditorExample />
<ClientOnly fallback={null}>
<div className="col col--6 col--offset-3">
<h2>Try it out!</h2>
<p>
Here's a simple example of a rich text editor built in Draft.js.
</p>
<div id="rich-example">
<DraftEditorExample />
</div>
</div>
</div>
</ClientOnly>
</div>
<div className="margin-vert--xl text--center">
<Link
Expand Down
Loading