You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* use snake_case component names * add settings.py to exclusive features * change light/dark mode icons * create docs tests * configure test workflows properly * rename workflow/jobs * remove alternative title on hooks page * format all docs
Copy file name to clipboardExpand all lines: README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ Any Python web framework with Websockets can support IDOM. See below for what fr
25
25
26
26
<!--py-header-start-->
27
27
28
-
You'll need a file to define your [IDOM](https://github.com/idom-team/idom) components. We recommend creating a `components.py` file within your chosen **Django app** to start out. Within this file, we will create a simple `HelloWorld` component.
28
+
You'll need a file to define your [IDOM](https://github.com/idom-team/idom) components. We recommend creating a `components.py` file within your chosen **Django app** to start out. Within this file, we will create a simple `hello_world` component.
29
29
30
30
<!--py-header-end-->
31
31
<!--py-code-start-->
@@ -34,7 +34,7 @@ You'll need a file to define your [IDOM](https://github.com/idom-team/idom) comp
34
34
from idom import component, html
35
35
36
36
@component
37
-
defHelloWorld(recipient: str):
37
+
defhello_world(recipient: str):
38
38
return html.h1(f"Hello {recipient}!")
39
39
```
40
40
@@ -46,7 +46,7 @@ def HelloWorld(recipient: str):
46
46
47
47
In your **Django app**'s HTML template, you can now embed your IDOM component using the `component` template tag. Within this tag, you will need to type in your dotted path to the component function as the first argument.
48
48
49
-
Additonally, you can pass in keyword arguments into your component function. For example, after reading the code below, pay attention to how the function definition for `HelloWorld` (_in the previous example_) accepts a `recipient` argument.
49
+
Additonally, you can pass in keyword arguments into your component function. For example, after reading the code below, pay attention to how the function definition for `hello_world` (_in the previous example_) accepts a `recipient` argument.
50
50
51
51
<!--html-header-end-->
52
52
<!--html-code-start-->
@@ -56,7 +56,7 @@ Additonally, you can pass in keyword arguments into your component function. For
Check out the [IDOM Core docs](https://idom-docs.herokuapp.com/docs/reference/hooks-api.html?highlight=hooks) on hooks!
@@ -13,13 +11,11 @@ from idom import component, html
13
11
from django_idom.hooks import use_websocket
14
12
15
13
@component
16
-
defMyComponent():
14
+
defmy_component():
17
15
my_websocket = use_websocket()
18
16
return html.div(my_websocket)
19
17
```
20
18
21
-
22
-
23
19
## Use Scope
24
20
25
21
This is a shortcut that returns the Websocket's `scope`.
@@ -29,17 +25,16 @@ from idom import component, html
29
25
from django_idom.hooks import use_scope
30
26
31
27
@component
32
-
defMyComponent():
28
+
defmy_component():
33
29
my_scope = use_scope()
34
30
return html.div(my_scope)
35
31
```
36
32
37
-
38
33
## Use Location
39
34
40
35
??? info "This hook's behavior will be changed in a future update"
41
36
42
-
This hook will be updated to return the browser's current URL. This will come in alongside our built-in [Single Page Application (SPA) support](https://github.com/idom-team/idom/issues/569).
37
+
This hook will be updated to return the browser's current URL. This change will come in alongside [IDOM URL routing support](https://github.com/idom-team/idom/issues/569).
43
38
44
39
This is a shortcut that returns the Websocket's `path`.
45
40
@@ -48,7 +43,7 @@ from idom import component, html
But keep in mind, in scenarios where you are trying to create a Single Page Application (SPA) within Django, you will only have one central component within your `#!html <body>` tag.
65
65
66
+
Additionally, the components in the example above will not be able to interact with each other, except through database queries.
0 commit comments