Don't include code in SSR generation of Playground endpoint (#1518)

Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1518

We allow arbitrary code in the query param, that static site generation doesn't know about. Current experience in production build is confusing, since you can see a flash of one set of code (playground default), quickly change to another. It is less confusing to have it go from blank to code showing.

Reviewed By: yungsters

Differential Revision: D52162928

fbshipit-source-id: fc7b51455682351a0616be8b9ecf557122d3a8db
This commit is contained in:
Nick Gerleman
2023-12-19 12:46:26 -08:00
committed by Facebook GitHub Bot
parent eeeb2cae49
commit 3f6f04cb92
3 changed files with 38 additions and 16 deletions

View File

@@ -28,16 +28,8 @@ import type {StyleNode} from './YogaViewer';
import styles from './Playground.module.css';
const defaultCode = `
<Layout config={{useWebDefaults: false}}>
<Node style={{width: 350, height: 350, padding: 20}}>
<Node style={{flex: 1}} />
</Node>
</Layout>
`.trim();
export type Props = Readonly<{
code?: string;
code: string;
height?: CSSProperties['height'];
autoFocus?: boolean;
}>;
@@ -46,7 +38,7 @@ export default function Playground({code, height, autoFocus}: Props) {
const prismTheme = usePrismTheme();
const editorScrollRef = useRef<HTMLDivElement>(null);
const [liveCode, setLiveCode] = useState(code ?? defaultCode);
const [liveCode, setLiveCode] = useState(code);
const [hasCodeChanged, setHasCodeChanged] = useState(false);
const [scrollbarWidth, setScrollbarWidth] = useState(0);