feat: make hooks free-functions
This commit is contained in:
1 parent
f782e14211
commit
e5c88fe3a4
13 files changed
+373
-323
No files matched your search
@@ -15,7 +15,8 @@ struct DogApi {
|
||||
const ENDPOINT: &str = "https://dog.ceo/api/breeds/image/random";
|
||||
|
||||
pub static Example: FC<()> = |cx| {
|
||||
let doggo = cx.use_suspense(
|
||||
let doggo = use_suspense(
|
||||
cx,
|
||||
|| surf::get(ENDPOINT).recv_json::<DogApi>(),
|
||||
|cx, res| match res {
|
||||
Ok(res) => rsx!(in cx, img { src: "{res.message}" }),
|
||||
|
||||
@@ -30,7 +30,7 @@ pub static Example: FC<()> = |cx| {
|
||||
|
||||
// Tasks are 'static, so we need to copy relevant items in
|
||||
let (async_count, dir) = (count.for_async(), *direction);
|
||||
let (task, result) = cx.use_task(move || async move {
|
||||
let (task, result) = use_task(cx, move || async move {
|
||||
// Count infinitely!
|
||||
loop {
|
||||
gloo_timers::future::TimeoutFuture::new(250).await;
|
||||
|
||||
Reference in new issue
Block a user