Skip to content

Commit 29be8e4

Browse files
committed
quick draft of offline docs
1 parent 53ba55c commit 29be8e4

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- [Distributed computing](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#reactpy_default_hosts)
2626
- [Performance enhancements](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#performance-settings)
2727
- [Customizable reconnection behavior](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#stability-settings)
28+
- [Customizable disconnection behavior](https://reactive-python.github.io/reactpy-django/latest/reference/template-tag)
2829
- [Multiple root components](https://reactive-python.github.io/reactpy-django/latest/reference/template-tag/)
2930
- [Django view to ReactPy component conversion](https://reactive-python.github.io/reactpy-django/latest/reference/components/#view-to-component)
3031
- [Django static file access](https://reactive-python.github.io/reactpy-django/latest/reference/components/#django-css)

docs/src/reference/template-tag.md

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This template tag can be used to insert any number of ReactPy components onto yo
2828
| `#!python key` | `#!python Any` | Force the component's root node to use a [specific key value](https://reactpy.dev/docs/guides/creating-interfaces/rendering-data/index.html#organizing-items-with-keys). Using `#!python key` within a template tag is effectively useless. | `#!python None` |
2929
| `#!python host` | `#!python str | None` | The host to use for the ReactPy connections. If unset, the host will be automatically configured.<br/>Example values include: `localhost:8000`, `example.com`, `example.com/subdir` | `#!python None` |
3030
| `#!python prerender` | `#!python str` | If `#!python "True"`, the component will pre-rendered, which enables SEO compatibility and reduces perceived latency. | `#!python "False"` |
31+
| `#!python offline` | `#!python str` | The dotted path to a component that will be displayed if your root component loses connection to the server. Keep in mind, this `offline` component will be non-interactive (hooks won't operate). | `#!python ""` |
3132
| `#!python **kwargs` | `#!python Any` | The keyword arguments to provide to the component. | N/A |
3233

3334
<font size="4">**Returns**</font>
@@ -66,26 +67,6 @@ This template tag can be used to insert any number of ReactPy components onto yo
6667

6768
<!--context-end-->
6869

69-
??? question "Can I render components on a different server (distributed computing)?"
70-
71-
Yes! This is most commonly done through [`settings.py:REACTPY_HOSTS`](../reference/settings.md#reactpy_default_hosts). However, you can use the `#!python host` keyword to render components on a specific ASGI server.
72-
73-
=== "my-template.html"
74-
75-
```jinja
76-
...
77-
{% component "example_project.my_app.components.do_something" host="127.0.0.1:8001" %}
78-
...
79-
```
80-
81-
This configuration most commonly involves you deploying multiple instances of your project. But, you can also create dedicated Django project(s) that only render specific ReactPy components if you wish.
82-
83-
Here's a couple of things to keep in mind:
84-
85-
1. If your host address are completely separate ( `origin1.com != origin2.com` ) you will need to [configure CORS headers](https://pypi.org/project/django-cors-headers/) on your main application during deployment.
86-
2. You will not need to register ReactPy WebSocket or HTTP paths on any applications that do not perform any component rendering.
87-
3. Your component will only be able to access your template tag's `#!python *args`/`#!python **kwargs` if your applications share a common database.
88-
8970
<!--multiple-components-start-->
9071

9172
??? question "Can I use multiple components on one page?"
@@ -111,7 +92,6 @@ This template tag can be used to insert any number of ReactPy components onto yo
11192
Additionally, in scenarios where you are trying to create a Single Page Application (SPA) within Django, you will only have one component within your `#!html <body>` tag.
11293

11394
<!--multiple-components-end-->
114-
<!--args-kwargs-start-->
11595

11696
??? question "Can I use positional arguments instead of keyword arguments?"
11797

@@ -129,4 +109,30 @@ This template tag can be used to insert any number of ReactPy components onto yo
129109
{% include "../../python/template-tag-args-kwargs.py" %}
130110
```
131111

132-
<!--args-kwargs-end-->
112+
??? question "Can I render components on a different server (distributed computing)?"
113+
114+
Yes! This is most commonly done through [`settings.py:REACTPY_HOSTS`](../reference/settings.md#reactpy_default_hosts). However, you can use the `#!python host` keyword to render components on a specific ASGI server.
115+
116+
=== "my-template.html"
117+
118+
```jinja
119+
...
120+
{% component "example_project.my_app.components.do_something" host="127.0.0.1:8001" %}
121+
...
122+
```
123+
124+
This configuration most commonly involves you deploying multiple instances of your project. But, you can also create dedicated Django project(s) that only render specific ReactPy components if you wish.
125+
126+
Here's a couple of things to keep in mind:
127+
128+
1. If your host address are completely separate ( `origin1.com != origin2.com` ) you will need to [configure CORS headers](https://pypi.org/project/django-cors-headers/) on your main application during deployment.
129+
2. You will not need to register ReactPy WebSocket or HTTP paths on any applications that do not perform any component rendering.
130+
3. Your component will only be able to access your template tag's `#!python *args`/`#!python **kwargs` if your applications share a common database.
131+
132+
??? question "Can I pre-render components for SEO compatibility?"
133+
134+
...
135+
136+
??? question "How do I show something when the client disconnects?"
137+
138+
...

0 commit comments

Comments
 (0)