feat: overhaul ssr

This commit is contained in:
Jonathan Kelley committed 2022-12-06 17:41:47 -08:00
1 parent e8ae1fb83e
commit 34d9aafe0e
16 files changed
+263 -561

No files matched your search

+2 -8
View File
@@ -29,17 +29,11 @@ fn state_shares() {
dom.mark_dirty(ScopeId(0));
_ = dom.render_immediate();
assert_eq!(
dom.base_scope().consume_context::<i32>().unwrap().as_ref(),
&1
);
assert_eq!(dom.base_scope().consume_context::<i32>().unwrap(), 1);
dom.mark_dirty(ScopeId(0));
_ = dom.render_immediate();
assert_eq!(
dom.base_scope().consume_context::<i32>().unwrap().as_ref(),
&2
);
assert_eq!(dom.base_scope().consume_context::<i32>().unwrap(), 2);
dom.mark_dirty(ScopeId(2));
assert_eq!(
+3 -1
View File
@@ -1,5 +1,7 @@
//! Tests related to safety of the library.
use std::rc::Rc;
use dioxus::prelude::*;
use dioxus_core::SuspenseContext;
@@ -18,5 +20,5 @@ fn root_node_isnt_null() {
// There should be a default suspense context
// todo: there should also be a default error boundary
assert!(scope.has_context::<SuspenseContext>().is_some());
assert!(scope.has_context::<Rc<SuspenseContext>>().is_some());
}
+3 -2
View File
@@ -2,6 +2,7 @@ use dioxus::core::ElementId;
use dioxus::core::{Mutation::*, SuspenseContext};
use dioxus::prelude::*;
use std::future::IntoFuture;
use std::rc::Rc;
use std::time::Duration;
#[tokio::test]
@@ -51,11 +52,11 @@ fn app(cx: Scope) -> Element {
fn suspense_boundary(cx: Scope) -> Element {
cx.use_hook(|| {
cx.provide_context(SuspenseContext::new(cx.scope_id()));
cx.provide_context(Rc::new(SuspenseContext::new(cx.scope_id())));
});
// Ensure the right types are found
cx.has_context::<SuspenseContext>().unwrap();
cx.has_context::<Rc<SuspenseContext>>().unwrap();
cx.render(rsx!(async_child {}))
}