Skip to content

Commit fb84879

Browse files
committed
ReactPy V2 changes
1 parent 169e33e commit fb84879

File tree

65 files changed

+2173
-2728
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2173
-2728
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from reactpy import component, html
2+
3+
4+
@component
5+
def hello_world():
6+
return html.div("Hello World")
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from jinja2 import Environment, FileSystemLoader
2+
from starlette.applications import Starlette
3+
from starlette.routing import Route
4+
from starlette.templating import Jinja2Templates
5+
6+
from reactpy.templatetags import ReactPyJinja
7+
8+
jinja_templates = Jinja2Templates(
9+
env=Environment(
10+
loader=FileSystemLoader("path/to/my_templates"),
11+
extensions=[ReactPyJinja],
12+
)
13+
)
14+
15+
16+
async def example_webpage(request):
17+
return jinja_templates.TemplateResponse(request, "my_template.html")
18+
19+
20+
starlette_app = Starlette(routes=[Route("/", example_webpage)])
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from jinja2 import Environment, FileSystemLoader
2+
from starlette.applications import Starlette
3+
from starlette.routing import Route
4+
from starlette.templating import Jinja2Templates
5+
6+
from reactpy.executors.asgi import ReactPyMiddleware
7+
from reactpy.templatetags import ReactPyJinja
8+
9+
jinja_templates = Jinja2Templates(
10+
env=Environment(
11+
loader=FileSystemLoader("path/to/my_templates"),
12+
extensions=[ReactPyJinja],
13+
)
14+
)
15+
16+
17+
async def example_webpage(request):
18+
return jinja_templates.TemplateResponse(request, "my_template.html")
19+
20+
21+
starlette_app = Starlette(routes=[Route("/", example_webpage)])
22+
reactpy_app = ReactPyMiddleware(starlette_app, ["my_components.hello_world"])
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<title>ReactPy in Django</title>
6+
</head>
7+
8+
<body>
9+
{% component "my_components.hello_world" %}
10+
</body>
11+
12+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from pathlib import Path
2+
3+
from reactpy.executors.asgi import ReactPyCsr
4+
5+
my_app = ReactPyCsr(
6+
Path(__file__).parent / "components" / "root.py", initial="Loading..."
7+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from reactpy import component, html
2+
3+
4+
@component
5+
def root():
6+
return html.div("Hello World")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from reactpy import component, html
2+
from reactpy.executors.asgi import ReactPy
3+
4+
5+
@component
6+
def hello_world():
7+
return html.div("Hello World")
8+
9+
10+
my_app = ReactPy(hello_world)

docs/examples/python/quick_start/adding_styles.py

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

docs/examples/python/responding_to_events/simple_button_event.py

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

docs/examples/python/start_a_new_react_project/configure_example.py

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

0 commit comments

Comments
 (0)