Skip to content

Commit acce1dd

Browse files
committed
exports_mount default as true
also update the docs
1 parent c4cab43 commit acce1dd

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

docs/source/examples/super_simple_chart.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
import React from "./react.js";
2-
import htm from "./htm.js";
1+
import { h, Component, render } from "https://unpkg.com/preact?module";
2+
import htm from "https://unpkg.com/htm?module";
33

4-
const html = htm.bind(React.createElement);
4+
const html = htm.bind(h);
5+
6+
export function mount(element, component, props) {
7+
const root = render(html`<${component} ...${props} />`, element);
8+
return () => {
9+
const Nothing = () => null;
10+
render(html`<${Nothing} />`, element, root);
11+
};
12+
}
513

614
export function SuperSimpleChart(props) {
715
const data = props.data;

docs/source/examples/super_simple_chart.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
import idom
44

55

6-
# we use this to make writing our React code a bit easier
7-
idom.install("htm")
8-
96
path_to_source_file = Path(__file__).parent / "super_simple_chart.js"
107
ssc = idom.Module("super-simple-chart", source_file=path_to_source_file)
118

src/idom/client/module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def __init__(
108108
source_type: Optional[str] = None,
109109
source_file: Optional[Union[str, Path]] = None,
110110
fallback: Optional[str] = None,
111-
exports_mount: bool = False,
111+
exports_mount: bool = True,
112112
check_exports: Optional[bool] = None,
113113
) -> None:
114114
self.source = source

src/idom/server/prefab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def run(
6363
port = find_available_port(host)
6464

6565
server = server_type(component, server_config, app)
66-
logger.info(f"Using {server}")
66+
logger.info(f"Using {type(server).__name__}")
6767

6868
run_server = server.run if not daemon else server.run_in_thread
6969
run_server(host, port, **(run_kwargs or {})) # type: ignore

tests/test_client/test_module.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ def victory():
1919

2020
@pytest.fixture(scope="module")
2121
def simple_button():
22-
return Module("simple-button", source_file=JS_FIXTURES / "simple-button.js")
22+
return Module(
23+
"simple-button",
24+
source_file=JS_FIXTURES / "simple-button.js",
25+
exports_mount=False,
26+
)
2327

2428

2529
def test_any_relative_or_abolute_url_allowed():
@@ -32,7 +36,7 @@ def test_any_relative_or_abolute_url_allowed():
3236
def test_module_import_repr():
3337
assert (
3438
repr(Module("/absolute/url/module").declare("SomeComponent"))
35-
== "Import(name='SomeComponent', source='/absolute/url/module', sourceType='URL', fallback=None, exportsMount=False)"
39+
== "Import(name='SomeComponent', source='/absolute/url/module', sourceType='URL', fallback=None, exportsMount=True)"
3640
)
3741

3842

@@ -58,7 +62,7 @@ def test_installed_module(driver, display, victory):
5862

5963

6064
def test_reference_pre_installed_module(victory):
61-
assert victory == idom.Module("victory")
65+
assert victory == idom.Module("victory", exports_mount=False)
6266

6367

6468
def test_module_from_url():

0 commit comments

Comments
 (0)