-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: switch trigger async render from script to island (#831)
* Add async render marker and utility function * Move useAsyncRender to web file * switch fresh async render trigger to an island
- Loading branch information
1 parent
e756771
commit 2ddc9ad
Showing
3 changed files
with
31 additions
and
49 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,23 @@ | ||
import { useEffect } from "preact/hooks"; | ||
|
||
interface Props { | ||
id: string; | ||
} | ||
|
||
export default function DispatchAsyncRender({ id }: Props) { | ||
useEffect(function clickOnAsyncRenderElements() { | ||
const elem = document.getElementById(id); | ||
const parent = elem?.parentElement; | ||
|
||
if (elem == null || parent == null) { | ||
console.error( | ||
`Missing element of id ${id} or its parent element. Async rendering will NOT work properly`, | ||
); | ||
return; | ||
} | ||
|
||
elem.click(); | ||
}, []); | ||
|
||
return <div data-dispatch-async-render />; | ||
} |
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