Skip to content

Commit fb657ed

Browse files
committed
update docs and export more from idom-client-react
1 parent fc0d3bc commit fb657ed

File tree

7 files changed

+321
-130
lines changed

7 files changed

+321
-130
lines changed

docs/source/_static/custom.js

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,21 @@ function Element({ model, key }) {
16081608
}
16091609
}
16101610

1611+
function elementChildren(modelChildren) {
1612+
if (!modelChildren) {
1613+
return [];
1614+
} else {
1615+
return modelChildren.map((child) => {
1616+
switch (typeof child) {
1617+
case "object":
1618+
return html`<${Element} key=${child.key} model=${child} />`;
1619+
case "string":
1620+
return child;
1621+
}
1622+
});
1623+
}
1624+
}
1625+
16111626
function StandardElement({ model }) {
16121627
const config = react.useContext(LayoutConfigContext);
16131628
const children = elementChildren(model.children);
@@ -1632,7 +1647,7 @@ function ImportedElement({ model }) {
16321647
if (fallback) {
16331648
importSource.then(() => {
16341649
reactDom.unmountComponentAtNode(mountPoint.current);
1635-
if ( mountPoint.current.children ) {
1650+
if (mountPoint.current.children) {
16361651
mountPoint.current.removeChild(mountPoint.current.children[0]);
16371652
}
16381653
});
@@ -1673,21 +1688,6 @@ function ImportedElement({ model }) {
16731688
}
16741689
}
16751690

1676-
function elementChildren(modelChildren) {
1677-
if (!modelChildren) {
1678-
return [];
1679-
} else {
1680-
return modelChildren.map((child) => {
1681-
switch (typeof child) {
1682-
case "object":
1683-
return html`<${Element} key=${child.key} model=${child} />`;
1684-
case "string":
1685-
return child;
1686-
}
1687-
});
1688-
}
1689-
}
1690-
16911691
function elementAttributes(model, sendEvent) {
16921692
const attributes = Object.assign({}, model.attributes);
16931693

@@ -1736,22 +1736,13 @@ function loadFromImportSource(config, importSource) {
17361736
typeof module.unmountElement == "function"
17371737
) {
17381738
return {
1739-
createElement: (type, props) =>
1740-
module.createElement(module[type], props),
1739+
createElement: (type, props, children) =>
1740+
module.createElement(module[type], props, children, config),
17411741
renderElement: module.renderElement,
17421742
unmountElement: module.unmountElement,
17431743
};
17441744
} else {
1745-
return {
1746-
createElement: (type, props, children) =>
1747-
react.createElement(
1748-
module[type],
1749-
props,
1750-
...elementChildren(children)
1751-
),
1752-
renderElement: reactDom.render,
1753-
unmountElement: reactDom.unmountComponentAtNode,
1754-
};
1745+
console.error(`${module} does not expose the required interfaces`);
17551746
}
17561747
});
17571748
}

docs/source/command-line.rst

Lines changed: 0 additions & 51 deletions
This file was deleted.

docs/source/faq.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ simple and one which allows you to do everything you normally would in Python.
2424
Does IDOM support any React component?
2525
--------------------------------------
2626

27-
If you :ref:`Dynamically Install Javascript` components, then the answer is no. Only
28-
components whose props are JSON serializable, or which expect basic callback functions
29-
similar to those of standard event handlers (e.g. ``onClick``) will operate as expected.
27+
If you use :ref:`Dynamically Loaded Components`, then the answer is no. Only components
28+
whose props are JSON serializable, or which expect basic callback functions similar to
29+
those of standard event handlers (e.g. ``onClick``) will operate as expected.
3030

31-
However, if you import a pre-built :ref:`Custom Javascript Component <Custom Javascript Components>`
31+
However, if you import a :ref:`Custom Javascript Component <Custom Javascript Components>`
3232
then, so long as the bundle has be defined appropriately, any component can be made to
3333
work, even those that don't rely on React.
3434

@@ -54,6 +54,8 @@ These restrictions apply because the Javascript from the CDN must be able to run
5454
natively in the browser and the module must be able to run in isolation from the main
5555
application.
5656

57+
See :ref:`Distributing Javascript via CDN_` for more info.
58+
5759

5860
What props can I pass to Javascript components?
5961
-----------------------------------------------

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ IDOM
1717

1818
core-concepts
1919
javascript-components
20-
command-line
2120
specifications
2221

2322
.. toctree::
@@ -41,6 +40,7 @@ IDOM
4140
A package for building highly interactive user interfaces in pure Python inspred by
4241
`ReactJS <https://reactjs.org/>`__.
4342

43+
4444
At a Glance
4545
-----------
4646

0 commit comments

Comments
 (0)