MCPcopy Index your code
hub / github.com/reactive-python/reactpy / mountWidgetExample

Function mountWidgetExample

docs/source/_custom_js/src/index.js:5–35  ·  view source on GitHub ↗
(
  mountID,
  viewID,
  reactpyServerHost,
  useActivateButton,
)

Source from the content-addressed store, hash-verified

3let didMountDebug = false;
4
5export function mountWidgetExample(
6 mountID,
7 viewID,
8 reactpyServerHost,
9 useActivateButton,
10) {
11 let reactpyHost, reactpyPort;
12 if (reactpyServerHost) {
13 [reactpyHost, reactpyPort] = reactpyServerHost.split(":", 2);
14 } else {
15 reactpyHost = window.location.hostname;
16 reactpyPort = window.location.port;
17 }
18
19 const client = new SimpleReactPyClient({
20 serverLocation: {
21 url: `${window.location.protocol}//${reactpyHost}:${reactpyPort}`,
22 route: "/",
23 query: `?view_id=${viewID}`,
24 },
25 });
26
27 const mountEl = document.getElementById(mountID);
28 let isMounted = false;
29 triggerIfInViewport(mountEl, () => {
30 if (!isMounted) {
31 activateView(mountEl, client, useActivateButton);
32 isMounted = true;
33 }
34 });
35}
36
37function activateView(mountEl, client, useActivateButton) {
38 if (!useActivateButton) {

Callers

nothing calls this directly

Calls 2

triggerIfInViewportFunction · 0.85
activateViewFunction · 0.85

Tested by

no test coverage detected