Skip to content

Commit 2e6bf21

Browse files
committed
Misc docs updates
1 parent c80f94d commit 2e6bf21

9 files changed

+29
-38
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Using the following categories, list your changes in this order:
5050

5151
### Changed
5252

53-
- Simplified code for cascading deletion of UserData.
53+
- Simplified code for cascading deletion of user data.
5454

5555
## [3.7.0] - 2024-01-30
5656

docs/examples/python/configure-asgi-middleware.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
application = ProtocolTypeRouter(
1212
{
1313
"http": django_asgi_app,
14-
"websocket": AuthMiddlewareStack(
15-
URLRouter(
16-
[REACTPY_WEBSOCKET_ROUTE],
17-
)
18-
),
14+
"websocket": AuthMiddlewareStack(URLRouter([REACTPY_WEBSOCKET_ROUTE])),
1915
}
2016
)

docs/examples/python/use-channel-layer.py

+11-17
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,20 @@
33

44

55
@component
6-
def my_sender_component():
7-
sender = use_channel_layer("my-channel-name")
6+
def my_component():
7+
async def receive_message(message):
8+
set_message(message["text"])
89

9-
async def submit_event(event):
10+
async def send_message(event):
1011
if event["key"] == "Enter":
1112
await sender({"text": event["target"]["value"]})
1213

13-
return html.div(
14-
"Message Sender: ",
15-
html.input({"type": "text", "onKeyDown": submit_event}),
16-
)
17-
18-
19-
@component
20-
def my_receiver_component():
2114
message, set_message = hooks.use_state("")
15+
sender = use_channel_layer("my-channel-name", receiver=receive_message)
2216

23-
async def receive_event(message):
24-
set_message(message["text"])
25-
26-
use_channel_layer("my-channel-name", receiver=receive_event)
27-
28-
return html.div(f"Message Receiver: {message}")
17+
return html.div(
18+
f"Received: {message}",
19+
html.br(),
20+
"Send: ",
21+
html.input({"type": "text", "onKeyDown": send_message}),
22+
)

docs/examples/python/user-passes-test-component-fallback.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ def my_component_fallback():
77
return html.div("I am NOT logged in!")
88

99

10-
def auth_check(user):
10+
def is_authenticated(user):
1111
return user.is_authenticated
1212

1313

14-
@user_passes_test(auth_check, fallback=my_component_fallback)
14+
@user_passes_test(is_authenticated, fallback=my_component_fallback)
1515
@component
1616
def my_component():
1717
return html.div("I am logged in!")

docs/examples/python/user-passes-test-vdom-fallback.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
from reactpy_django.decorators import user_passes_test
33

44

5-
def auth_check(user):
5+
def is_authenticated(user):
66
return user.is_authenticated
77

88

9-
@user_passes_test(auth_check, fallback=html.div("I am NOT logged in!"))
9+
@user_passes_test(is_authenticated, fallback=html.div("I am NOT logged in!"))
1010
@component
1111
def my_component():
1212
return html.div("I am logged in!")

docs/examples/python/user-passes-test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
from reactpy_django.decorators import user_passes_test
33

44

5-
def auth_check(user):
5+
def is_authenticated(user):
66
return user.is_authenticated
77

88

9-
@user_passes_test(auth_check)
9+
@user_passes_test(is_authenticated)
1010
@component
1111
def my_component():
1212
return html.div("I am logged in!")

docs/src/reference/hooks.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -536,15 +536,15 @@ This is useful when used in combination with [`#!python use_channel_layer`](#use
536536

537537
??? example "See Interface"
538538

539-
<font size="4">**Parameters**</font>
539+
<font size="4">**Parameters**</font>
540540

541-
`#!python None`
541+
`#!python None`
542542

543-
<font size="4">**Returns**</font>
543+
<font size="4">**Returns**</font>
544544

545-
| Type | Description |
546-
| --- | --- |
547-
| `#!python str` | A string containing the root component's `#!python id`. |
545+
| Type | Description |
546+
| --- | --- |
547+
| `#!python str` | A string containing the root component's `#!python id`. |
548548

549549
---
550550

docs/src/reference/management-commands.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ReactPy exposes Django management commands that can be used to perform various R
1212

1313
Command used to manually clean ReactPy data.
1414

15-
When using this command without arguments, it will perform all cleaning operations. You can specify only performing specific cleaning operations through arguments such as `--sessions`.
15+
When using this command without arguments, it will perform all cleaning operations. You can limit cleaning to specific operations through arguments such as `--sessions`.
1616

1717
!!! example "Terminal"
1818

docs/src/reference/settings.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ This setting is incompatible with [`daphne`](https://github.com/django/daphne).
131131

132132
The default host(s) that can render your ReactPy components.
133133

134-
ReactPy will use these hosts in a round-robin fashion, allowing for easy distributed computing.
134+
ReactPy will use these hosts in a round-robin fashion, allowing for easy distributed computing. This is typically useful for self-hosted applications.
135135

136136
You can use the `#!python host` argument in your [template tag](../reference/template-tag.md#component) to manually override this default.
137137

@@ -147,9 +147,10 @@ Configures whether to pre-render your components via HTTP, which enables SEO com
147147

148148
During pre-rendering, there are some key differences in behavior:
149149

150-
1. Only the component's first render is pre-rendered.
150+
1. Only the component's first paint is pre-rendered.
151151
2. All [`connection` hooks](https://reactive-python.github.io/reactpy-django/latest/reference/hooks/#connection-hooks) will provide HTTP variants.
152152
3. The component will be non-interactive until a WebSocket connection is formed.
153+
4. The component is re-rendered once a WebSocket connection is formed.
153154

154155
<!-- TODO: The comment below will become true when ReactPy no longer strips scripts from the DOM -->
155156
<!-- 4. `#!python html.script` elements are executed twice (pre-render and post-render). -->

0 commit comments

Comments
 (0)