We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5075f97 commit 3a7f4b3Copy full SHA for 3a7f4b3
README.md
@@ -45,13 +45,10 @@ IDOM can be used to create a simple slideshow which changes whenever a user clic
45
import idom
46
47
@idom.element
48
-async def Slideshow(self, index=0):
49
-
50
- async def next_image(event):
51
- self.update(index + 1)
52
+async def Slideshow():
+ index, set_index = idom.hooks.use_state(0)
53
url = f"https://picsum.photos/800/300?image={index}"
54
- return idom.html.img({"src": url, "onClick": next_image})
+ return idom.html.img({"src": url, "onClick": lambda event: set_index(index + 1)})
55
56
server = idom.server.sanic.PerClientState(Slideshow)
57
server.daemon("localhost", 8765).join()
0 commit comments