-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.10.0 (3) switch rehydration mismatch protection to `useSyncExternal…
…Store` (#207) * add test for race condition * switch to `useSyncExternalStore` * add comments * fix up tests * move React functions out of test * disable semgrep * Update packages/client-react-streaming/src/DataTransportAbstraction/WrappedApolloClient.test.tsx Co-authored-by: Jerel Miller <[email protected]> * remove some `await test` calls --------- Co-authored-by: Jerel Miller <[email protected]>
- Loading branch information
1 parent
d98b87b
commit 100952e
Showing
4 changed files
with
173 additions
and
15 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
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,33 @@ | ||
import { hydrateRoot } from "react-dom/client"; | ||
|
||
/* eslint-disable */ | ||
// prettier-ignore | ||
/** React completeSegment function */ | ||
// @ts-expect-error This is React code. | ||
export function $RS(a, b) { a = document.getElementById(a); b = document.getElementById(b); for (a.parentNode.removeChild(a); a.firstChild;)b.parentNode.insertBefore(a.firstChild, b); b.parentNode.removeChild(b) } | ||
// prettier-ignore | ||
/** React completeBoundary function */ | ||
// @ts-expect-error This is React code. | ||
export function $RC(b, c, e = undefined) { c = document.getElementById(c); c.parentNode.removeChild(c); var a = document.getElementById(b); if (a) { b = a.previousSibling; if (e) b.data = "$!", a.setAttribute("data-dgst", e); else { e = b.parentNode; a = b.nextSibling; var f = 0; do { if (a && 8 === a.nodeType) { var d = a.data; if ("/$" === d) if (0 === f) break; else f--; else "$" !== d && "$?" !== d && "$!" !== d || f++ } d = a.nextSibling; e.removeChild(a); a = d } while (a); for (; c.firstChild;)e.insertBefore(c.firstChild, a); b.data = "$" } b._reactRetry && b._reactRetry() } } | ||
/* eslint-enable */ | ||
|
||
export function hydrateBody( | ||
initialChildren: Parameters<typeof hydrateRoot>[1], | ||
options?: Parameters<typeof hydrateRoot>[2] | ||
) { | ||
return hydrateRoot(document.body, initialChildren, options); | ||
} | ||
|
||
export function setBody(html: TemplateStringsArray) { | ||
if (html.length !== 1) | ||
throw new Error("Expected exactly one template string"); | ||
// nosemgrep | ||
document.body.innerHTML = html[0]; | ||
} | ||
|
||
export function appendToBody(html: TemplateStringsArray) { | ||
if (html.length !== 1) | ||
throw new Error("Expected exactly one template string"); | ||
// nosemgrep | ||
document.body.insertAdjacentHTML("beforeend", html[0]); | ||
} |