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

Commit

Permalink
Don't SSR example editor on website. (#2356)
Browse files Browse the repository at this point in the history
Summary:
There's suspicion the example editor fails in prod because of an SSR error, so lets not SSR-it. Also upgrades draft to the latest version on npm.
Pull Request resolved: #2356

Test Plan: `yarn start`, played around with the editor.

Reviewed By: claudiopro

Differential Revision: D20532633

Pulled By: mrkev

fbshipit-source-id: 934427d2e1a35232ee9f12632e539817a1f2eaa8
  • Loading branch information
mrkev authored and facebook-github-bot committed Mar 19, 2020
1 parent 7ba51a3 commit 9191a3f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1,246 deletions.
2 changes: 1 addition & 1 deletion website/package.json
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
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

0 comments on commit 9191a3f

Please sign in to comment.