generated from kriasoft/react-starter-kit
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.tsx
20 lines (17 loc) · 753 Bytes
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* SPDX-FileCopyrightText: 2014-present Kriasoft <hello@kriasoft.com> */
/* SPDX-License-Identifier: MIT */
import history from "history/browser";
import * as React from "react";
import * as ReactDOM from "react-dom";
import { App } from "./common";
import { createRelay } from "./core/relay";
// Dehydrate the initial API response and initialize a Relay store
// https://developer.mozilla.org/docs/Web/HTML/Element/script#embedding_data_in_html
const data = (document.getElementById("data") as HTMLScriptElement).text;
const records = data ? JSON.parse(data) : undefined;
const relay = createRelay({ records });
// Render the top-level React component
ReactDOM.render(
<App history={history} relay={relay} />,
document.getElementById("root")
);