import { getTinyliciousContainer } from "@fluid-experimental/get-container" ; import { getDefaultObjectFromContainer } from "@fluidframework/aqueduct" ; import React from "react" ; import ReactDOM from "react-dom" ; import { Likes } from "./fluidObject" ; import { LikesContainer } from "./container" ; import { LikesView } from "./view" ; /**
 * This is a helper function for loading the page. It's required because getting the Fluid Container
 * requires making async calls.
 */ async function start ( ) { const shouldCreateNew = location . hash . length === 0 ; const documentId = ! shouldCreateNew ? window . location . hash . substring ( 1 ) : "" ; const [ container , containerId ] = await getTinyliciousContainer ( documentId , LikesContainer , shouldCreateNew ) ; location . hash = containerId ; document . title = containerId ; const defaultObject = await getDefaultObjectFromContainer < Likes > ( container ) ; const contentDiv = document . getElementById ( "content" ) ; if ( contentDiv !== null ) { ReactDOM . render ( < LikesView syncedDataObject = { defaultObject } / > , contentDiv ) ; } window [ "fluidStarted" ] = true ; } start ( ) . catch ( ( e ) => { console . error ( e ) ; console . log ( "%cEnsure you are running the Tinylicious Fluid Server" , "font-size:30px" ) ; } ) ;