-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use React 18 renderer and fix empty cell bug
- Loading branch information
Showing
5 changed files
with
36 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import H5webApp from './H5webApp'; | ||
import { useMeasure } from '@react-hookz/web'; | ||
|
||
interface Props { | ||
path: string; | ||
} | ||
|
||
function H5WebInCell(props: Props) { | ||
const { path } = props; | ||
|
||
// Wait for cell to have non-empty size so H5Web can render safely | ||
const [rect, cellRef] = useMeasure<HTMLDivElement>(); | ||
|
||
return ( | ||
<div ref={cellRef} className="h5web-in-cell"> | ||
{rect && rect.width > 0 && <H5webApp filePath={path} />} | ||
</div> | ||
); | ||
} | ||
|
||
export default H5WebInCell; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,9 @@ | ||
import React, { useEffect, useMemo, useState } from 'react'; | ||
import React, { useMemo } from 'react'; | ||
import { App, getFeedbackMailto, H5GroveProvider } from '@h5web/app'; | ||
import { ServerConnection } from '@jupyterlab/services'; | ||
|
||
const FEEDBACK_EMAIL = '[email protected]'; | ||
|
||
function TwoRenderApp() { | ||
const [isFirstRender, setIsFirstRender] = useState(true); | ||
|
||
useEffect(() => { | ||
setIsFirstRender(false); | ||
}, []); | ||
|
||
if (isFirstRender) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<App | ||
getFeedbackURL={(context) => getFeedbackMailto(context, FEEDBACK_EMAIL)} | ||
disableDarkMode | ||
/> | ||
); | ||
} | ||
|
||
function H5webApp(props: { filePath: string }) { | ||
const { filePath } = props; | ||
const { baseUrl, token } = ServerConnection.makeSettings(); | ||
|
@@ -42,7 +23,12 @@ function H5webApp(props: { filePath: string }) { | |
filepath={filePath} | ||
axiosConfig={axiosConfig} | ||
> | ||
<TwoRenderApp /> | ||
<App | ||
getFeedbackURL={(context) => | ||
getFeedbackMailto(context, FEEDBACK_EMAIL) | ||
} | ||
disableDarkMode | ||
/> | ||
</H5GroveProvider> | ||
</div> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters